File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 11// Predict and explain first...
22// =============> write your prediction here
33
4+ // I predict that the function will capitalise the first character of the string
5+ // And then return a string using string interpolation using the first character of the string
6+ // and a slice of the remaining characters of the string excluding the first character.
7+
48// call the function capitalise with a string input
59// interpret the error message and figure out why an error is occurring
610
@@ -10,4 +14,13 @@ function capitalise(str) {
1014}
1115
1216// =============> write your explanation here
17+
18+ // An error is thrown because of the variable name collision. The function has a parameter called `str`
19+ // but in the body of the function, a variable `str` is declared and that conflicts with the parameter.
20+
1321// =============> write your new code here
22+
23+ function upperCased ( string ) {
24+ const capitalised = `${ string [ 0 ] . toUpperCase ( ) } ${ string . slice ( 1 ) } ` ;
25+ return capitalised ;
26+ }
You can’t perform that action at this time.
0 commit comments