Skip to content

Commit 69c00ce

Browse files
fix key error in 0.js - duplicate str variable
1 parent d28242a commit 69c00ce

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
//I think this code will show a SyntaxError. The function has two variables named str in the same scope.
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+
let result = `${str[0].toUpperCase()}${str.slice(1)}`;
9+
return result;
1010
}
11-
12-
// =============> write your explanation here
13-
// =============> write your new code here
11+
console.log(capitalise("hello"));
12+
// str is used both as the function parameter (function capitalise(str)) and again in let str = ...

0 commit comments

Comments
 (0)