File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// Predict and explain first...
2- // =============> write your prediction here
2+ /* =============> I predict that the function would make 1st character uppercase and
3+ then adds the rest of the string using slice. */
34
45// call the function capitalise with a string input
56// interpret the error message and figure out why an error is occurring
67
8+ //We cannot declare str again because it has already been declared as a parameter of the function.
9+
10+ /* OLD CODE
11+
712function capitalise(str) {
813 let str = `${str[0].toUpperCase()}${str.slice(1)}`;
914 return str;
1015}
16+ */
1117
1218// =============> write your explanation here
1319// =============> write your new code here
20+
21+ function capitalise ( str ) {
22+ str = `${ str [ 0 ] . toUpperCase ( ) } ${ str . slice ( 1 ) } ` ;
23+ return str ;
24+ }
You can’t perform that action at this time.
0 commit comments