Skip to content

Commit 704d372

Browse files
committed
Console and const
Swapped the position of const from under the console to on top of the console to allow javascript to read it in order.
1 parent c557dca commit 704d372

File tree

1 file changed

+3
-1
lines changed
  • Sprint-1/2-mandatory-errors

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
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+
// The error happens because cityOfBirth is used before it is defined. JavaScript runs code from top to bottom, so the variable must be declared first.

0 commit comments

Comments
 (0)