Skip to content

Commit 0f63b87

Browse files
committed
I have finished KeyErrors 0
1 parent 3372770 commit 0f63b87

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 3372770a4d6ae71b931968a6d6deb70dda58a065

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// =============> 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.
33

44
// call the function capitalise with a string input
5+
capitalise("hello world");
56
// interpret the error message and figure out why an error is occurring
7+
// Error message: SyntaxError: Identifier 'str' has already been declared. The error is because the variable str has already been declared.
68

79
function capitalise(str) {
8-
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
9-
return str;
10+
let newStr = `${str[0].toUpperCase()}${str.slice(1)}`;
11+
return newStr;
1012
}
1113

12-
// =============> write your explanation here
13-
// =============> write your new code here
14+
// =============> I've given the variable a new name, newStr, to avoid redclaring the variable.
15+
// =============> function capitalise(str) {
16+
// let newStr = `${str[0].toUpperCase()}${str.slice(1)}`;
17+
// return newStr;
18+
//}

0 commit comments

Comments
 (0)