File tree Expand file tree Collapse file tree 1 file changed +2
-10
lines changed
Expand file tree Collapse file tree 1 file changed +2
-10
lines changed Original file line number Diff line number Diff line change 11// Predict and explain first...
22// =============> write your prediction here
3- //the function will turn the first given string into Uppercase.
43
54// call the function capitalise with a string input
65// interpret the error message and figure out why an error is occurring
76
87function capitalise ( str ) {
9- let strWithUpperCase = `${ str [ 0 ] . toUpperCase ( ) } ${ str . slice ( 1 ) } ` ;
10- return strWithUpperCase ;
8+ let str = `${ str [ 0 ] . toUpperCase ( ) } ${ str . slice ( 1 ) } ` ;
9+ return str ;
1110}
1211
1312// =============> write your explanation here
14- // str[0].toUpperCase() ---> gets the first character and uses build-in method to convert a char to uppercase
15- // str.slice(1) ----> will slice the array or sting "start from 1" to the rest of array or string
16- // we get an error because we "re-declare" the str variable as parameter and as call back of expression
17-
1813// =============> write your new code here
19-
20- const myStr = "i forgot add this string" ;
21- console . log ( capitalise ( myStr ) ) ;
You can’t perform that action at this time.
0 commit comments