-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0.js
More file actions
20 lines (19 loc) · 814 Bytes
/
Copy path0.js
File metadata and controls
20 lines (19 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Predict and explain first...
// =============> write your prediction here
// it will take a string and turn the first letter into a capital.
// call the function capitalise with a string input
// interpret the error message and figure out why an error is occurring
// SyntaxError: Identifier 'str' has already been declared - str cannot be used twice as a variable name.
function capitalise(str) {
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
return str;
}
// =============> write your explanation here
// i've changed the variable name from str to result. This corrected the error and return result.
// =============> write your new code here
function capitalise(str) {
let result = `${str[0].toUpperCase()}${str.slice(1)}`;
console.log("result",result);
return result;
}
capitalise("pear")