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
Copy file name to clipboardExpand all lines: Sprint-1/2-mandatory-errors/2.js
+7Lines changed: 7 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -3,3 +3,10 @@
3
3
4
4
console.log(`I was born in ${cityOfBirth}`);
5
5
constcityOfBirth="Bolton";
6
+
7
+
// ERROR: Cannot access 'cityOfBirth' before initialization console.log(`I was born in ${cityOfBirth}`); // ERROR: Cannot access 'cityOfBirth' before initialization
8
+
// Fixed: Swapped the line order to resolve the ReferenceError.
9
+
10
+
11
+
constcityOfBirth="Bolton";
12
+
console.log(`I was born in ${cityOfBirth}`);// SUCCESS: Variable is initialized first
0 commit comments