Skip to content

Commit 6ce8a2e

Browse files
committed
constant cannot be reassigned
1 parent 29a9fe7 commit 6ce8a2e

File tree

1 file changed

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

1 file changed

+6
-0
lines changed

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

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

33
const age = 33;
44
age = age + 1;
5+
// This will cause an error because age is a constant and cannot be reassigned
6+
console.log("I am " + age + " years old");
7+
// To fix the error, we can change const to let, which allows reassignment
8+
let age = 33;
9+
age = age + 1;
10+
console.log("I am " + age + " years old");

0 commit comments

Comments
 (0)