Skip to content

Commit e3dd609

Browse files
authored
predict,explain and update the error
1 parent 8f3d6cf commit e3dd609

File tree

1 file changed

+13
-6
lines changed
  • Sprint-2/1-key-errors

1 file changed

+13
-6
lines changed

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
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) {
8-
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
9-
return str;
10-
}
8+
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
9+
return str;
10+
11+
// =============> 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.
1112

12-
// =============> write your explanation here
13-
// =============> write your new code here
13+
// =============> write your new code here :
14+
/*
15+
function capitalise(str) {
16+
let cap = `${str[0].toUpperCase()}${str.slice(1)}`;
17+
return cap;
18+
}
19+
console.log(capitalise("str"));
20+
*/

0 commit comments

Comments
 (0)