Skip to content

Commit cedc8a3

Browse files
committed
Comment about variable hoisting
1 parent ce03285 commit cedc8a3

File tree

1 file changed

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

1 file changed

+3
-2
lines changed

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

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

4-
// this is a very common JavaScript error related to variable hoisting and the temporal dead zone.
5-
// Simply declare the variable before you use it
4+
// This is related to variable hoisting.
5+
// const keywork is a block scope and unlike var it's not hoisted automatically.
6+
// The easiest solution is to declare the variable before to use it
67

78
const cityOfBirth = "Bolton";
89
console.log(`I was born in ${cityOfBirth}`);

0 commit comments

Comments
 (0)