-
-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy path0.js
More file actions
29 lines (22 loc) · 898 Bytes
/
0.js
File metadata and controls
29 lines (22 loc) · 898 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
28
29
// Predict and explain first...
// =============> write your prediction here
/*
My prediction is that this function will take the first letter of a string and capital it.
*/
// 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;
}*/
// =============> write your explanation here
/*
The main reason why the capitalise function have a not define error because the the str variable have been declare in the parameter
inside the function, the str variable is re-declare again that will break the rule of how variable work.
*/
// =============> write your new code here
function capitalise(str) {
let firstCapitaLetter = `${str[0].toUpperCase()}${str.slice(1)}`;
return firstCapitaLetter;
};
console.log(capitalise("hello"));