File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change 11// Predict and explain first...
22// =============> write your prediction here
3+ //we should have an error showing that str already exists so we cannot declare it again inside the function.
34
45// call the function capitalise with a string input
56// interpret the error message and figure out why an error is occurring
67
7- function capitalise ( str ) {
8- let str = `${ str [ 0 ] . toUpperCase ( ) } ${ str . slice ( 1 ) } ` ;
9- return str ;
10- }
8+ //function capitalise(str) {
9+ // let str = `${str[0].toUpperCase()}${str.slice(1)}`;
10+ // return str;
11+ //}
12+
13+ //console.log(capitalise("cat"));
1114
1215// =============> write your explanation here
16+ //str has been passed down as a parameter so we cannot declare it again. we would need to declare a different variable name.
1317// =============> write your new code here
18+ function capitalise ( str ) {
19+ let capitalisedStr = `${ str [ 0 ] . toUpperCase ( ) } ${ str . slice ( 1 ) } ` ;
20+ return capitalisedStr ;
21+ }
22+
23+ console . log ( capitalise ( "cat" ) ) ;
You can’t perform that action at this time.
0 commit comments