Skip to content

Commit caf0ecd

Browse files
Fix age reassignment error
1 parent 491dfc7 commit caf0ecd

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • Sprint-2/2-mandatory-errors

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// trying to create an age variable and then reassign the value by 1
22

3-
const age = 33;
3+
let age = 33;
44
age = age + 1;
5+
console.log(age);
56

67
// Error: TypeError
7-
// Why: age was declared with const, so it cannot be reassigned.
8+
// Why: Assignment to constant variable.
9+
// Fix: Changed const to let, which allows the variable to be reassigned.

0 commit comments

Comments
 (0)