Skip to content

Commit c9dbc7a

Browse files
committed
Predict, Explain and Write new code
1 parent 8f3d6cf commit c9dbc7a

File tree

1 file changed

+12
-4
lines changed
  • Sprint-2/1-key-errors

1 file changed

+12
-4
lines changed

Sprint-2/1-key-errors/0.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// =============> write your prediction here : There will be an error.
33

44
// call the function capitalise with a string input
55
// interpret the error message and figure out why an error is occurring
66

77
function capitalise(str) {
88
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
99
return str;
10-
}
1110

12-
// =============> write your explanation here
13-
// =============> write your new code here
11+
12+
// =============> write your explanation here : Because str has been used(declared) twice. As an input(parameter) to the function(capitalise) and with let. We should used a different variable.
13+
14+
// =============> write your new code here :
15+
/*
16+
function capitalise(str) {
17+
let cap = `${str[0].toUpperCase()}${str.slice(1)}`;
18+
return cap;
19+
}
20+
console.log(capitalise("fares"));
21+
*/

0 commit comments

Comments
 (0)