File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 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- }
7+ // function capitalise(str) {
8+ // let str = `${str[0].toUpperCase()}${str.slice(1)}`;
9+ // return str;
10+ // }
1111
1212// =============> write your explanation here
1313
1414// Error at line 8
1515//SyntaxError: Identifier 'str' has already been declared
16+ // the function has alreayd a parameter called "str"and
17+ // we are trying decare a new variable with the same name
1618
1719// =============> write your new code here
1820
21+ function capitalise ( str ) {
22+ let newCap = `${ str [ 0 ] . toUpperCase ( ) } ${ str . slice ( 1 ) } ` ;
23+ return newCap ;
24+ }
25+ console . log ( capitalise ( "hello" ) ) ;
26+ console . log ( capitalise ( "apple" ) ) ;
You can’t perform that action at this time.
0 commit comments