Skip to content

Commit 2076556

Browse files
committed
Fixed variable redeclaration in capitalise function and update comments for clarity
1 parent db2d6dd commit 2076556

File tree

1 file changed

+8
-3
lines changed
  • Sprint-2/1-key-errors

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// =============> there are two declarations of the variable str.
33

44
// call the function capitalise with a string input
55
// interpret the error message and figure out why an error is occurring
@@ -9,5 +9,10 @@ function capitalise(str) {
99
return str;
1010
}
1111

12-
// =============> write your explanation here
13-
// =============> write your new code here
12+
// =============> str is declared twice in the function capitalise and using let.
13+
14+
// =============> we delete the 'let'
15+
function capitalise(str) {
16+
str = `${str[0].toUpperCase()}${str.slice(1)}`;
17+
return str;
18+
}

0 commit comments

Comments
 (0)