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 81e5bf5 commit 9584255Copy full SHA for 9584255
Sprint-1/2-mandatory-errors/2.js
@@ -1,5 +1,13 @@
1
// Currently trying to print the string "I was born in Bolton" but it isn't working...
2
// what's the error ?
3
-
+// ReferenceError: Cannot access 'cityOfBirth' before initialization
4
+/*
5
console.log(`I was born in ${cityOfBirth}`);
6
+let cityOfBirth = "Bolton";
7
+*/
8
+// The error is because cityOfBirth is declared with const and is being accessed before its declaration.
9
+// Changing const to let to help solve the problem.
10
+// I am also declaring the variable 'cityOfBirth' before before using it.
11
const cityOfBirth = "Bolton";
12
+console.log(`I was born in ${cityOfBirth}`);
13
+// Output: I was born in Bolton
0 commit comments