We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c0c20fc commit 934aeecCopy full SHA for 934aeec
Sprint-1/2-mandatory-errors/2.js
@@ -1,5 +1,14 @@
1
// Currently trying to print the string "I was born in Bolton" but it isn't working...
2
// what's the error ?
3
4
-console.log(`I was born in ${cityOfBirth}`);
5
const cityOfBirth = "Bolton";
+console.log(`I was born in ${cityOfBirth}`);
6
+
7
+//ReferenceError: Cannot access 'cityOfBirth' before initialization
8
9
+// This is happening because we are trying to use the variable cityOfBirth
10
+// before it has been declared and assigned a value.
11
12
+// Variables declared with let and const can't be accessed before they are initialized.
13
14
+// To fix this error, we need to declare and assign a value to cityOfBirth before we try to log it to the console.
0 commit comments