-
-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy path0.js
More file actions
17 lines (14 loc) · 674 Bytes
/
0.js
File metadata and controls
17 lines (14 loc) · 674 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Predict and explain first...
// =============> The error will be that the variable str is being redefined within the function. It was already defined when it was passed as an arguement.
// call the function capitalise with a string input
capitalise("hello world");
// interpret the error message and figure out why an error is occurring
// Error message: SyntaxError: Identifier 'str' has already been declared. The error is because the variable str has already been declared.
function capitalise(str) {
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
return str;
}
// //function capitalise(str) {
// return str[0].toUpperCase() + str.slice(1);
// }
// //}