Skip to content

Commit e52f37a

Browse files
committed
fix duplicate declaration in sprint 3 key error 0
1 parent 358846c commit e52f37a

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// Prediction: I think the code will have a SyntaxError because 'str' is declared twice.
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;
8+
return `${str[0].toUpperCase()}${str.slice(1)}`;
109
}
1110

12-
// =============> write your explanation here
13-
// =============> write your new code here
11+
// Explanation: The function already has something called str. You can't make a second thing with the same name inside the same function
12+
// New code: removed the 'let str =' line and returned the expression directly.

0 commit comments

Comments
 (0)