File tree Expand file tree Collapse file tree 1 file changed +6
-21
lines changed
Expand file tree Collapse file tree 1 file changed +6
-21
lines changed Original file line number Diff line number Diff line change 11// Predict and explain first...
2- // =============> write your prediction here:
3- // I think their will be an error because of the str tag
4-
5-
6-
7-
2+ // =============> write your prediction here
83
94// call the function capitalise with a string input
10- console . log ( capitalise ( "hello" ) ) ; // should print "Hello"
11-
12-
135// interpret the error message and figure out why an error is occurring
146
7+ function capitalise ( str ) {
8+ let str = `${ str [ 0 ] . toUpperCase ( ) } ${ str . slice ( 1 ) } ` ;
9+ return str ;
10+ }
1511
16- //function capitalise(str) {
17- //let str = `${str[0].toUpperCase()}${str.slice(1)}`;
18- //return str;
19- //}
20-
21- // =============> write your explanation here:
22- // str is being used as both the function parameter and a variable inside the function, causing a conflict.
23-
24-
12+ // =============> write your explanation here
2513// =============> write your new code here
26-
27- function capitalise ( inputStr ) {
28- return `${ inputStr [ 0 ] . toUpperCase ( ) } ${ inputStr . slice ( 1 ) } ` ; }
You can’t perform that action at this time.
0 commit comments