-
-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy path0.js
More file actions
29 lines (21 loc) · 903 Bytes
/
0.js
File metadata and controls
29 lines (21 loc) · 903 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
// call the function capitalise with a string input
// interpret the error message and figure out why an error is occurring
function capitalise(str) {
let outputStr = `${str[0].toUpperCase()}${str.slice(1)}`;
console.log(outputStr);
return outputStr;
}
capitalise("edak");
// =============> write your explanation here
//expecting the function to return the characters of the string, with the first character capitalized.
//syntaxError: Identifier 'str' has already been declared.
// The variable str has already been passed as parameter in the function (), declaring it again cause an identity error
// =============> write your new code here
// function capitalise(str) {
// let outputStr = `${str[0].toUpperCase()}${str.slice(1)}`;
// console.log(outputStr);
// return outputStr;
//};
//capitalise('edak')