Skip to content

Commit d477732

Browse files
committed
move variable declaration before use to avoid ReferenceError
1 parent 1b0b5b3 commit d477732

File tree

1 file changed

+3
-1
lines changed
  • Sprint-1/2-mandatory-errors

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Currently trying to print the string "I was born in Bolton" but it isn't working...
22
// what's the error ? The error here is due to using a variable before it's declared.
33

4-
console.log(`I was born in ${cityOfBirth}`);
4+
5+
// Fixed: Declare the variable before using it
56
const cityOfBirth = "Bolton";
7+
console.log(`I was born in ${cityOfBirth}`);

0 commit comments

Comments
 (0)