-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0.js
More file actions
27 lines (19 loc) · 969 Bytes
/
Copy path0.js
File metadata and controls
27 lines (19 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Predict and explain first...
// =============> write your prediction here
// The code will capitalize the first word of the str which gives "Str"
// call the function capitalise with a string input
// interpret the error message and figure out why an error is occurring
// The error occurs in line 13 and it says "SyntaxError: Identifier 'str' has already been declared"
// The error is informing us that the string str has already been declared in line 12 so we can not declare it again.
//function capitalise(str) {
// let str = `${str[0].toUpperCase()}${str.slice(1)}`;
// return str;
//}
// =============> write your explanation here
// The code is written to capitalize the first letter of str which is expected to give the result Str.
// =============> write your new code here
function capitalise(firstLetters) {
firstLetters = `${firstLetters[0].toUpperCase()}${firstLetters.slice(1)}`;
return firstLetters;
}
console.log(capitalise("hello"))