File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 77// call the function capitalise with a string input
88// interpret the error message and figure out why an error is occurring
99
10- function capitalise ( str ) {
11- let str = `${ str [ 0 ] . toUpperCase ( ) } ${ str . slice ( 1 ) } ` ;
12- return str ;
13- }
10+ // function capitalise(str) {
11+ // let str = `${str[0].toUpperCase()}${str.slice(1)}`;
12+ // return str;
13+ // }
1414
15- // =============> write your explanation here => The error occurs because you cannot declare
15+ // =============> write your explanation here => The error occurs because we cannot declare
1616// a new variable with the same name as a function parameter (str) using let inside the function.
17- // This causes a "Identifier 'str' has already been declared" error.
17+ // This causes a "Identifier 'str' has already been declared" error according to mdn .
1818
1919
2020// =============> write your new code here
2121function capitalise ( str ) {
2222 return `${ str [ 0 ] . toUpperCase ( ) } ${ str . slice ( 1 ) } ` ;
23- }
23+ }
24+
25+ console . log ( capitalise ( "bethan" ) ) ;
You can’t perform that action at this time.
0 commit comments