Skip to content

Commit 3966773

Browse files
committed
Fixed reference error by declaring cityOfBirth before using it.
1 parent ac2cdb5 commit 3966773

File tree

1 file changed

+5
-0
lines changed
  • Sprint-1/2-mandatory-errors

1 file changed

+5
-0
lines changed

Sprint-1/2-mandatory-errors/2.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
// Currently trying to print the string "I was born in Bolton" but it isn't working...
22
// what's the error ?
33

4+
45
console.log(`I was born in ${cityOfBirth}`);
56
const cityOfBirth = "Bolton";
7+
8+
// Reference error:can not access "cityOfBirth" before initialization
9+
// in this code the variable "cityOfBirth" is used before it is been declared"
10+
// solution: Move the const line above the console.log

0 commit comments

Comments
 (0)