Skip to content

Commit 352f54e

Browse files
committed
Debugged and updated the code.
1 parent d28242a commit 352f54e

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,19 @@
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 str = `${str[0].toUpperCase()}${str.slice(1)}`;
9+
return str;
1010
}
1111

1212
// =============> write your explanation here
13+
// The function parameter declares the variable string in the first line and then the variable is declared again using let. This will not run because you cannot declare a variable with the same name twice.
14+
// The return returns the same variable making the funtion useless.
15+
// The is no console.log() to print anything.
1316
// =============> write your new code here
17+
18+
function capitalise(str) {
19+
let capitalisedStr = `${str[0].toUpperCase()}${str.slice(1)}`;
20+
return capitalisedStr;
21+
}
22+
let result = capitalise("str")
23+
console.log(result);

0 commit comments

Comments
 (0)