File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
Expand file tree Collapse file tree 1 file changed +15
-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+ // }
11+
12+ // console.log(capitalise("lowercase"));
1113
1214// =============> write your explanation here
15+ // The error states str has already been declared. This is because str is the parameter and within the
16+ // function it is trying to declare a new variable with the same name using let.
17+
1318// =============> write your new code here
19+ function capitalise ( str ) {
20+ let newStr = `${ str [ 0 ] . toUpperCase ( ) } ${ str . slice ( 1 ) } ` ;
21+ return newStr ;
22+ }
23+
24+ console . log ( capitalise ( "lowercase" ) ) ;
You can’t perform that action at this time.
0 commit comments