File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments