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 7
7
// call the function capitalise with a string input
8
8
// interpret the error message and figure out why an error is occurring
9
9
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
+ // }
14
14
15
- // =============> write your explanation here => The error occurs because you cannot declare
15
+ // =============> write your explanation here => The error occurs because we cannot declare
16
16
// 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 .
18
18
19
19
20
20
// =============> write your new code here
21
21
function capitalise ( str ) {
22
22
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