Skip to content

Commit 54784c1

Browse files
committed
Updated answer to 2-mandatory-errors/1.js to make code works. Eexplanation/answers included as text
1 parent 630fa14 commit 54784c1

File tree

1 file changed

+5
-2
lines changed
  • Sprint-1/2-mandatory-errors

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
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;
5-
//problem: we cannot reassign a value to a variable that has been declared with "const". We can solve this problem by changing the declaration of the variable from "const" to "let", which allows us to reassign values to the variable. So we would change the first line to "let age = 33;".
6+
console.log(age);
7+
8+
//problem: we cannot reassign a value to a variable that has been declared with "const". We can solve this problem by changing the declaration of the variable from "const" to "let", which allows us to reassign values to the variable. So I have commed line 3 and added line 4 to "let age = 33;". Also, I have added a line at the end to log the value of age to the console, so we can see the result of the reassignment to check that it is working correctly.

0 commit comments

Comments
 (0)