Skip to content

Commit b2957b1

Browse files
Fix variable initialization error
1 parent caf0ecd commit b2957b1

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

  • Sprint-2/2-mandatory-errors

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +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+
67

7-
// Error: ReferenceError: Cannot access 'cityOfBirth' before initialization
8-
// Why: cityOfBirth is used before it is declared.
8+
// Error: ReferenceError:
9+
// Why: Cannot access 'cityOfBirth' before initialization
10+
// Fix: Declare the const before using it

0 commit comments

Comments
 (0)