File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change 11// Predict and explain first...
2- // =============> write your prediction here
2+ // I think this function is meant to make the first letter of a string into uppercase then return the string
33
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+ // I got the error "SyntaxError: Identifier 'str' has already been declared"
13+ // This is because str had been declared in line 7 and let str in line 8 is also trying to declare str
14+
15+ // to fix this, I just removed the word let in line 8. This gave a value to str without trying to declare it again
16+ // I ran the new code and there were no errors
17+
718function capitalise ( str ) {
8- let str = `${ str [ 0 ] . toUpperCase ( ) } ${ str . slice ( 1 ) } ` ;
19+ str = `${ str [ 0 ] . toUpperCase ( ) } ${ str . slice ( 1 ) } ` ;
920 return str ;
10- }
11-
12- // =============> write your explanation here
13- // =============> write your new code here
21+ }
You can’t perform that action at this time.
0 commit comments