-
-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy path1.js
More file actions
10 lines (8 loc) · 518 Bytes
/
1.js
File metadata and controls
10 lines (8 loc) · 518 Bytes
1
2
3
4
5
6
7
8
9
10
// trying to create an age variable and then reassign the value by 1
/* const age = 33;
age = age + 1;
*/
// This code will throw an error because we are trying to reassign a value to a constant variable (age). In JavaScript, once a variable is declared with const, its value cannot be changed. To fix this error, we can either change the declaration to let or var, which allows for reassignment, or we can create a new variable to store the updated age. For example:
let age = 33;
age = age + 1;
console.log(age);