Skip to content

Commit ca7fa61

Browse files
removed let from the code
1 parent 3372770 commit ca7fa61

File tree

1 file changed

+14
-6
lines changed
  • Sprint-2/1-key-errors

1 file changed

+14
-6
lines changed

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// I think this function is meant to make the first letter of a string into uppercase then return the string
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) {
8+
// let str = `${str[0].toUpperCase()}${str.slice(1)}`;
9+
// return str;
10+
//}
11+
12+
// I got the error "SyntaxError: Identifier 'str' has already been declared"
13+
// This is because str had been declared in line 7 and let str in line 8 is also trying to declare str
14+
15+
// to fix this, I just removed the word let in line 8. This gave a value to str without trying to declare it again
16+
// I ran the new code and there were no errors
17+
718
function capitalise(str) {
8-
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
19+
str = `${str[0].toUpperCase()}${str.slice(1)}`;
920
return str;
10-
}
11-
12-
// =============> write your explanation here
13-
// =============> write your new code here
21+
}

0 commit comments

Comments
 (0)