Skip to content

Commit 3bc535d

Browse files
answer 2.2 e
1 parent d03f49e commit 3bc535d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • Sprint-2/2-mandatory-errors

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
console.log(`I was born in ${cityOfBirth}`);
55
const cityOfBirth = "Bolton";
66

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.
7+
The error in the code is that the variable `cityOfBirth` is being used before it is declared and assigned a value.
8+
9+
The Corrected code should be as follows:
810

911
const cityOfBirth = "Bolton";
1012

0 commit comments

Comments
 (0)