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...
22// =============> write your prediction here
3-
4- // call the function capitalise with a string input
3+ // Well, I think the variable "str" is being declared twice, so the code will
4+ // through an error message.
5+ //
6+ //call the function capitalise with a string input
57// interpret the error message and figure out why an error is occurring
68
79function capitalise ( str ) {
@@ -10,4 +12,12 @@ function capitalise(str) {
1012}
1113
1214// =============> write your explanation here
15+ //The variable "str" has been used as a parameter for the capitalise function
16+ //and also been declared again inside the function. I think if "let" is removed
17+ //the code will work.
1318// =============> write your new code here
19+ function capitalise ( str ) {
20+ str = `${ str [ 0 ] . toUpperCase ( ) } ${ str . slice ( 1 ) } ` ;
21+ return str ;
22+ }
23+ console . log ( capitalise ( "sorted" ) ) ;
You can’t perform that action at this time.
0 commit comments