Skip to content

Commit 1234dae

Browse files
committed
fix error in 2js
1 parent ee6445d commit 1234dae

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • Sprint-2/2-mandatory-errors

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@
33

44
console.log(`I was born in ${cityOfBirth}`);
55
const cityOfBirth = "Bolton";
6+
7+
/* The log is trying to use cityOfBirth before the variable exists.
8+
JavaScript reads the code in order, so the variable must be declared before it is used.*/
9+
// I logged the message before creating the cityOfBirth variable, so JavaScript couldn't find it yet. I need to declare the variable before using it.
10+
const cityOfBirth = "Bolton";
11+
console.log(`I was born in ${cityOfBirth}`);

0 commit comments

Comments
 (0)