You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Currently trying to print the string "I was born in Bolton" but it isn't working...
2
2
// what's the error ?
3
3
4
-
console.log(`I was born in ${cityOfBirth}`);
5
4
constcityOfBirth="Bolton";
5
+
console.log(`I was born in ${cityOfBirth}`);
6
+
7
+
// Error:** `ReferenceError: Cannot access 'cityOfBirth' before initialization (at 2.js:4:30)`
8
+
9
+
// Cause:** Line 4 is trying to use `cityOfBirth` before the variable has been created. The variable is only declared on line 5, and JavaScript processes the code from top to bottom.
10
+
11
+
// Fix:** Declare and assign `cityOfBirth` before using it in the code.
0 commit comments