There was an error while loading. Please reload this page.
1 parent d9ef102 commit 1915855Copy full SHA for 1915855
1 file changed
Sprint-2/2-mandatory-errors/2.js
@@ -1,5 +1,11 @@
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
+//const cityOfBirth = "Bolton";
7
+
8
+/* When we try to run our code it is giving us an error saying ReferenceError: Cannot access 'cityOfBirth' before initialization
9
+and this is because we tried to access the var cityOfBirth before we declared and initialized it*/
10
11
+// We can overcome this error by declaring and initializing the var cityOfBirth before accessing it
0 commit comments