Skip to content

Commit 7e9bb59

Browse files
committed
Completed exercise 1
1 parent 24151e5 commit 7e9bb59

File tree

1 file changed

+15
-4
lines changed
  • Sprint-2/1-key-errors

1 file changed

+15
-4
lines changed

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,21 @@
44
// call the function capitalise with a string input
55
// interpret the error message and figure out why an error is occurring
66

7-
function capitalise(str) {
8-
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
9-
return str;
10-
}
7+
// function capitalise(str) {
8+
// let str = `${str[0].toUpperCase()}${str.slice(1)}`;
9+
// return str;
10+
// }
11+
12+
// console.log(capitalise("lowercase"));
1113

1214
// =============> write your explanation here
15+
// The error states str has already been declared. This is because str is the parameter and within the
16+
// function it is trying to declare a new variable with the same name using let.
17+
1318
// =============> write your new code here
19+
function capitalise(str) {
20+
let newStr = `${str[0].toUpperCase()}${str.slice(1)}`;
21+
return newStr;
22+
}
23+
24+
console.log(capitalise("lowercase"));

0 commit comments

Comments
 (0)