Skip to content

Commit 7291d85

Browse files
committed
I fixed the error and wrote a new code, it runs perfectly
1 parent 07075e1 commit 7291d85

File tree

1 file changed

+5
-2
lines changed
  • Sprint-2/1-key-errors

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
// call the function capitalise with a string input
66
// interpret the error message and figure out why an error is occurring
77

8-
8+
function capitalise(str) {
9+
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
10+
return str;
11+
}
912

1013
// =============> write your explanation here
11-
// The error happened because 'str' was declared twice: once as a parameter and once with 'let' inside the function.
14+
// The error happened because 'str' was declared twice, once as a parameter and once with 'let' inside the function.
1215
// Also, when calling the function, using a word without quotes caused a ReferenceError.
1316
// After removing the duplicate declaration and passing a string with quotes, the function works correctly,
1417
// =============> write your new code here

0 commit comments

Comments
 (0)