Skip to content

Commit e113639

Browse files
committed
Solved task 1-key-errors/0.js
1 parent 8907408 commit e113639

File tree

1 file changed

+10
-4
lines changed
  • Sprint-2/1-key-errors

1 file changed

+10
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@
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+
// So, the error sounds "SyntaxError: Identifier 'str' has already been declared", it means that we can't declare the sane variable name twice
13+
// =============> write your new code here
714
function capitalise(str) {
8-
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
9-
return str;
15+
let capitalisedStr = `${str[0].toUpperCase()}${str.slice(1)}`;
16+
return capitalisedStr;
1017
}
1118

12-
// =============> write your explanation here
13-
// =============> write your new code here
19+
console.log(capitalise("greetings")); // Output: "Greetings"

0 commit comments

Comments
 (0)