-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0.js
More file actions
23 lines (18 loc) · 820 Bytes
/
0.js
File metadata and controls
23 lines (18 loc) · 820 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Predict and explain first...
// =============> write your prediction here
//we should have an error showing that str already exists so we cannot declare it again inside the function.
// 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;
//}
//console.log(capitalise("cat"));
// =============> write your explanation here
//str has been passed down as a parameter so we cannot declare it again. we would need to declare a different variable name.
// =============> write your new code here
function capitalise(str) {
let capitalisedStr = `${str[0].toUpperCase()}${str.slice(1)}`;
return capitalisedStr;
}
console.log(capitalise("cat"));