There was an error while loading. Please reload this page.
1 parent 57efea5 commit 895a754Copy full SHA for 895a754
1 file changed
Sprint-2/2-mandatory-errors/1.js
@@ -1,4 +1,15 @@
1
// trying to create an age variable and then reassign the value by 1
2
-
3
-const age = 33;
+let age= 33;
4
age = age + 1;
+
5
+console.log (age);
6
7
8
9
+const means that the variable age is a constant and cannot be reassigned. When we try to reassign the value of age by adding 1 to it, we get an error.
10
+This is because we cannot change the value of a constant variable once we have created it.
11
12
+If we want to change the value of age, we need to use let instead of consts when declaring the variable. this then allows us to reassign the value of age by adding 1 to it.
13
14
15
0 commit comments