Skip to content

Commit b9e9f5c

Browse files
committed
resolve syntax error in 1-key-errors 0.js and comment
1 parent b31a586 commit b9e9f5c

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

  • Sprint-2/1-key-errors

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// The issue might be that the input to the function is str but also there is a variable declaration str inside it
33

44
// call the function capitalise with a string input
55
// interpret the error message and figure out why an error is occurring
66

7-
function capitalise(str) {
7+
function capitalise("hello") {
88
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
99
return str;
1010
}
1111

12-
// =============> write your explanation here
13-
// =============> write your new code here
12+
// Uncaught SyntaxError: Identifier 'str' has already been declared - meaning str should not have been used inside the function or the parameter of the function
13+
function capitalise(str) {
14+
let capitalisedStr = `${str[0].toUpperCase()}${str.slice(1)}`;
15+
return str;
16+
}

0 commit comments

Comments
 (0)