-
-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy path0.js
More file actions
18 lines (15 loc) · 689 Bytes
/
0.js
File metadata and controls
18 lines (15 loc) · 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Predict and explain first...
// =============> the function is not going to work because a variable is declared twice (str)
// call the function capitalise with a string input
// interpret the error message and figure out why an error is occurring
function capitalise(str) {
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
return str;
}
// =============> the error message 'Identifier 'str' has already been declared', diplays because the toUpperCase function does not change the value of the varible declared
// but it creates a new one.
// =============> my new code:
function capitalise(str) {
let result = `${str[0].toUpperCase()}${str.slice(1)}`;
return resault;
}