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: I predict that the code should cut out, and make the first letter of the string an uppercase letter,
2+ // ======> write your prediction here:
3+ // Answer below:
4+
5+ // I predict that the code should make the first letter of the string an uppercase letter,
36// then add every letters that comes after
47
58// call the function capitalise with a string input
69// interpret the error message and figure out why an error is occurring
710
8- // function capitalise(str) {
9- // let str= `${str[0].toUpperCase()}${str.slice(1)}`
10- // return str;
11- // }
1211
12+ // =============> write your explanation here:
13+ // Answer below:
1314
14- // =============> write your explanation here: The error read "SyntaxError: Identifier 'str' has already been declared",
15- // this is as a result of having two variables with same name. The error occoured in this code because the variable "str" has been decleared twice
15+ // The error read "SyntaxError: Identifier 'str' has already been declared",
16+ // This is as a result of having two variables with same name "str".
17+ // The error occoured in this code because the variable "str" has been declared twice
1618
1719// =============> write your new code here
1820
1921function capitalise ( str ) {
2022 return str = `${ str [ 0 ] . toUpperCase ( ) } ${ str . slice ( 1 ) } ` ;
2123}
22- console . log ( capitalise ( "money" ) )
24+ console . log ( capitalise ( "money" ) ) ;
You can’t perform that action at this time.
0 commit comments