Skip to content

Commit a9cb566

Browse files
committed
Fix capitalise function variable redeclaration
1 parent 2300ec7 commit a9cb566

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

  • Sprint-3/1-key-errors

‎Sprint-3/1-key-errors/0.js‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
3-
2+
// =============> We will have syntax error because string is the parameter of the function and the next line,it is declared wit let
3+
//so it is declared two times in one part
44
// call the function capitalise with a string input
5+
6+
7+
function capitalise(str) {
8+
str = `${str[0].toUpperCase()}${str.slice(1)}`;
9+
return str;
10+
}
11+
console.log(capitalise("mother"));
512
// interpret the error message and figure out why an error is occurring
613

714
function capitalise(str) {
815
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
916
return str;
1017
}
1118

12-
// =============> write your explanation here
13-
// =============> write your new code here
19+
// =============> write your explanation here SyntaxError: Identifier 'str' has already been declared
20+
// =============> write your new code here.
21+
function capitalise(str) {
22+
return `${str[0].toUpperCase()}${str.slice(1)}`;
23+
}

0 commit comments

Comments
 (0)