Skip to content

Commit d9ef102

Browse files
committed
fixing the error by changing the declaration keyword
1 parent 8f0d2a6 commit d9ef102

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • Sprint-2/2-mandatory-errors

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

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

3-
const age = 33;
3+
//const age = 33;
4+
let age = 33;
45
age = age + 1;
6+
console.log(age);
7+
8+
/* When we try to run the code it is giving us an error message saying TypeError: Assignment to constant variable,
9+
this error is telling us that we are trying to perform an operation on a value that is not the correct type,
10+
in our case reassigning a cons variable. The cons keyword prevents us from reassigning a variable
11+
We can overcome the error by changing the declaration keyword to "let"
12+
*/

0 commit comments

Comments
 (0)