Skip to content

Commit 8098b0e

Browse files
fix: correct syntax error in capitalise function and update comments
1 parent bf4817e commit 8098b0e

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// It will make the first letter in the string input capitalised.
33

44
// call the function capitalise with a string input
55
// interpret the error message and figure out why an error is occurring
6+
// "SyntaxError: Identifier 'str' has already been declared"
7+
8+
// capitalise("matthaus enjoys foood.")
9+
10+
// function capitalise(str) {
11+
// let str = `${str[0].toUpperCase()}${str.slice(1)}`;
12+
// return str;
13+
// }
14+
15+
// The error is thrown by declaring the 'str' variable again in the function with 'let' which causes it throw the SyntaxError, as it is already been declared.
16+
17+
capitalise("matthaus enjoys food")
618

719
function capitalise(str) {
8-
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
9-
return str;
20+
return '${str[0].toUpperCase()}${str.slice(1)}';
1021
}
11-
12-
// =============> write your explanation here
13-
// =============> write your new code here
22+
console.log(return);

0 commit comments

Comments
 (0)