Skip to content

Commit 194c793

Browse files
committed
Added original code and moved my code to end
1 parent 5f75bcf commit 194c793

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,20 @@
1313
// call the function capitalise with a string input
1414
// interpret the error message and figure out why an error is occurring
1515

16-
function capitalise(str) {
17-
str = `${str[0].toUpperCase()}${str.slice(1)}`;
18-
return str;
19-
}
16+
// function capitalise(str) {
17+
// let str = `${str[0].toUpperCase()}${str.slice(1)}`;
18+
// return str;
19+
// }
20+
2021

2122
// =============> write your explanation here
2223
// let str = `${str[0].toUpperCase()}${str.slice(1)}`;
2324
// I was right, error given is because of let str within the function.
2425
// SyntaxError: Identifier 'str' has already been declared
2526
// We cannot have two declarations of the same variable so we remove the let inside .capitalise.
2627
// =============> write your new code here
28+
function capitalise(str) {
29+
str = `${str[0].toUpperCase()}${str.slice(1)}`;
30+
return str;
31+
}
2732
console.log(capitalise("frankocean"))

0 commit comments

Comments
 (0)