Skip to content

Commit d03f49e

Browse files
answer 2.2
1 parent 550150b commit d03f49e

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • Sprint-2/2-mandatory-errors

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

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

44
console.log(`I was born in ${cityOfBirth}`);
55
const cityOfBirth = "Bolton";
6+
7+
The error in the code is that the variable `cityOfBirth` is being used before it is declared and assigned a value. In JavaScript, variables declared with `const` (or `let`) are not hoisted in the same way as `var`, meaning they cannot be accessed before their declaration.
8+
9+
const cityOfBirth = "Bolton";
10+
11+
console.log(`I was born in ${cityOfBirth}`);

0 commit comments

Comments
 (0)