-
-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy path0.js
More file actions
18 lines (15 loc) · 804 Bytes
/
0.js
File metadata and controls
18 lines (15 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// 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;
}
// =============> I've given the variable a new name, newStr, to avoid redclaring the variable.
// =============> function capitalise(str) {
// let newStr = `${str[0].toUpperCase()}${str.slice(1)}`;
// return newStr;
//}