There was an error while loading. Please reload this page.
1 parent 895a754 commit b786029Copy full SHA for b786029
1 file changed
Sprint-2/2-mandatory-errors/2.js
@@ -1,5 +1,17 @@
1
// Currently trying to print the string "I was born in Bolton" but it isn't working...
2
// what's the error ?
3
4
+error
5
+
6
console.log(`I was born in ${cityOfBirth}`);
7
const cityOfBirth = "Bolton";
8
9
+The reason there is an error is because we are using the wrong order, we are telling Javascript to print the value of cityOfBirth before creating a variable.
10
+So we need to create the variable first, this is because Javascript runs code from top to bottom, so a variable that is declared with const needs to be declared before using it.
11
12
13
14
+right way
15
16
+const cityOfBirth = "Bolton";
17
+console.log (`I was born in ${cityOfBirth}`);
0 commit comments