Skip to content

Commit 16a9631

Browse files
committed
change 1.0
1 parent 5dc9452 commit 16a9631

File tree

1 file changed

+12
-5
lines changed
  • Sprint-2/1-key-errors

1 file changed

+12
-5
lines changed

Sprint-2/1-key-errors/0.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
// Predict and explain first...
22
// =============> write your prediction here
3+
// I believe the code is trying to write the first letter of a string on capital letter. But since the "str" declaration has already been used, we will need a new name
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+
// }
1112

12-
// =============> write your explanation here
13+
// =============> write your explanation here: //There is a SynthaxError on line 9 of the code when we try to declare a new variable with the name "str". This is because the "str" name has already been used when declaring the function "capitalise".
1314
// =============> write your new code here
15+
function capitalise(str) {
16+
let name = `${str[0].toUpperCase()}${str.slice(1)}`;
17+
return name;
18+
}
19+
let str = "emma";
20+
console.log(capitalise(str));

0 commit comments

Comments
 (0)