Skip to content

Commit bc34e0e

Browse files
committed
1-key-error task completed
1 parent 51e9adc commit bc34e0e

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

  • Sprint-3/1-key-errors

‎Sprint-3/1-key-errors/0.js‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// ======> write your prediction here: I predict that the code should cut out, and make the first letter of the string an uppercase letter,
3+
// then add every letters that comes after
34

45
// call the function capitalise with a string input
56
// interpret the error message and figure out why an error is occurring
67

7-
function capitalise(str) {
8-
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
9-
return str;
10-
}
8+
// function capitalise(str) {
9+
// let str= `${str[0].toUpperCase()}${str.slice(1)}`
10+
// return str;
11+
// }
12+
13+
14+
// =============> write your explanation here: The error read "SyntaxError: Identifier 'str' has already been declared",
15+
// this is as a result of having two variables with same name. The error occoured in this code because the variable "str" has been decleared twice
1116

12-
// =============> write your explanation here
1317
// =============> write your new code here
18+
19+
function capitalise(str) {
20+
let str2= `${str[0].toUpperCase()}${str.slice(1)}`
21+
return str2;
22+
}
23+
console.log(capitalise("money"))

0 commit comments

Comments
 (0)