Skip to content

Commit 95adf58

Browse files
committed
explained using a comment and initialised cityOfBirth variable on line 3
1 parent 4d81b9f commit 95adf58

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • Sprint-2/2-mandatory-errors

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Currently trying to print the string "I was born in Bolton" but it isn't working...
22
// what's the error ?
3-
4-
console.log(`I was born in ${cityOfBirth}`);
53
const cityOfBirth = "Bolton";
4+
console.log(`I was born in ${cityOfBirth}`);
5+
6+
// the variable was initially declared after console.log so it threw an error message. The error message "cannot access 'cityOfBirth' before initialization at Object" is saying that javascript cannot access the variable before it has been initialised. I have initialised the variable on line 3 now so the message prints in the console now.

0 commit comments

Comments
 (0)