Skip to content

Commit b12c3a3

Browse files
authored
Fix variable reference error in console log
Reorder variable declaration and console log to fix reference error.
1 parent adcbbf9 commit b12c3a3

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

  • Sprint-2/2-mandatory-errors

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Currently trying to print the string "I was born in Bolton" but it isn't working...
22
// what's the error ?
3+
//The variable was declared after the print function, so the program doesn't know what is cityofBirth. Therefore, it can't perform the print function or execute before declaring the variable
34

4-
console.log(`I was born in ${cityOfBirth}`);
5-
const cityOfBirth = "Bolton";
5+
//to solve this, we reverse the order of both lines so the declaration comes before the print functions
66

7-
// the variable was declared after the print function so the program doesn't know what is cityofBirth. Therefore it can't perform the print function or excuted before declaring the variable
7+
const cityOfBirth = "Bolton";
8+
console.log(`I was born in ${cityOfBirth}`);

0 commit comments

Comments
 (0)