Skip to content

Commit e4c6e45

Browse files
Fix 1.js: use let instead of const to allow reassignment
1 parent 3986f03 commit e4c6e45

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

  • Sprint-2/2-mandatory-errors

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
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+
6+
// Error: TypeError: Assignment to constant variable. (at 1.js:4:5)
7+
// Cause: On line 4, the code is trying to change the value of `age`. However,
8+
// `age` was created using `const`, which means its value cannot be
9+
// changed after it has been assigned.
10+
// Fix: If the value of a variable needs to change later, use `let` instead of `const`.

0 commit comments

Comments
 (0)