Skip to content

Commit eff1a8f

Browse files
committed
2.js
1 parent 34cf88c commit eff1a8f

File tree

1 file changed

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

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
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}`);
4+
/*
5+
This happens because in JavaScript, variables declared with `let` or `const` are not accessible before their declaration
6+
due to a behavior called the **temporal dead zone**.
7+
If you try to use such a variable before it’s initialized, you get a `ReferenceError`.
8+
To avoid this, always declare and assign your variables before using them.
9+
10+
*/
511
const cityOfBirth = "Bolton";
12+
console.log(`I was born in ${cityOfBirth}`);
13+

0 commit comments

Comments
 (0)