|
1 | 1 | // Predict and explain first... |
2 | 2 | // =============> write your prediction here |
3 | | -//function capitalize will capitalise the first letter with index 0 |
4 | | -// and will append the sliced string from index 1 which is the second letter |
| 3 | +/* |
| 4 | +I predict the function will throw a SyntaxError as the variable str has already been declared in the function parameter |
| 5 | +function capitalize will capitalise the first letter with index 0 |
| 6 | +and will append the sliced string from index 1 which is the second letter |
| 7 | +*/ |
5 | 8 |
|
6 | | -// call the function capitalise with a string input |
| 9 | +//call the function capitalise with a string input |
7 | 10 |
|
8 | | -// interpret the error message and figure out why an error is occurring |
9 | | -//syntax Error :identifier the variabel has already been declared. |
10 | | -// As we can see the str variable has already been declared in the prameter of the function instead we just return the value |
11 | | -// The Error message is |
| 11 | +// interpret the error message and figure out why an error is occurring : |
| 12 | + |
| 13 | +/* syntax Error :identifier the variabel has already been declared. |
| 14 | +As we can see the str variable has already been declared in the prameter of the function instead we just return the value */ |
12 | 15 |
|
13 | 16 | // function capitalise(str) { |
14 | 17 | // let str = `${str[0].toUpperCase()}${str.slice(1)}`; |
|
18 | 21 |
|
19 | 22 |
|
20 | 23 | // =============> write your explanation here |
21 | | - |
22 | | -// =============> write your new code here |
| 24 | +/* syntax Error :identifier the variabel has already been declared. |
| 25 | +As we can see the str variable has already been declared in the prameter of the function instead we just return the value */ |
23 | 26 |
|
24 | 27 | function capitalise(str) { |
25 | | -return `${str[0].toUpperCase()}${str.slice(1)}`; |
| 28 | +return str[0].toUpperCase()+str.slice(1); |
26 | 29 |
|
27 | 30 | } |
28 | 31 | capitalise("ebrahim"); |
|
0 commit comments