Skip to content

Commit bad8580

Browse files
committed
Explained initialisation error and corrected variable order in 2.js
1 parent 658e7a7 commit bad8580

File tree

1 file changed

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

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,11 @@
33

44
console.log(`I was born in ${cityOfBirth}`);
55
const cityOfBirth = "Bolton";
6+
7+
// The error is that the variable cityOfBirth is used before it is declared and assigned a value.
8+
// To fix the error, we need to declare and assign a value to cityOfBirth before using it in the console.log statement.
9+
10+
/* Corrected code:
11+
const cityOfBirth = "Bolton";
12+
console.log(`I was born in ${cityOfBirth}`);
13+
*/

0 commit comments

Comments
 (0)