File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 33
44// call the function capitalise with a string input
55// interpret the error message and figure out why an error is occurring
6-
6+ /*
77function capitalise(str) {
88 let str = `${str[0].toUpperCase()}${str.slice(1)}`;
99 return str;
1010}
11-
11+ */
1212// =============> write your explanation here
13+ //Undeclared variables are automatically declared when first used. As a parameter in the 'capitalise' function,
14+ // 'str' is already declared. trying to declare it again with 'let' will cause a syntax error.
15+
1316// =============> write your new code here
17+ function capitalise ( str ) {
18+ str = `${ str [ 0 ] . toUpperCase ( ) } ${ str . slice ( 1 ) } ` ;
19+ return str ;
20+ }
21+ console . log ( capitalise ( "hello world" ) ) ; // This line is inserted only to test the code. It returns "Hello world"
You can’t perform that action at this time.
0 commit comments