Skip to content

Commit 7aea539

Browse files
committed
updated file 2.js with the fix
1 parent 5eac7a2 commit 7aea539

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎Sprint-2/2-mandatory-errors/1.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
// trying to create an age variable and then reassign the value by 1
22

3-
const age = 33;
3+
let age = 33;
44
age = age + 1;
5+
6+
console.log(age)
7+
8+
// The TypeError: Assignment to constant variable implies we are trying to reassign the variable twice.
9+
// This case, I have used let instead in order to allow the variable to be reused.

‎Sprint-2/2-mandatory-errors/2.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
// Currently trying to print the string "I was born in Bolton" but it isn't working...
22
// what's the error ?
33

4-
console.log(`I was born in ${cityOfBirth}`);
54
const cityOfBirth = "Bolton";
5+
console.log(`I was born in ${cityOfBirth}`);
6+
7+
8+
// The error is ReferenceError: Cannot access 'cityOfBirth' before initialization
9+
// Answer: the correct variable is not called
10+
// I changed the console to print the actual variable value

0 commit comments

Comments
 (0)