this is how you do decrement myVar–
in this tutorial myVar is already declared on line 1 . so you don’t need to declare it again
all you have to do is change the value with myVar with myVar-- because “myVar-1” is same as ‘myVar–’
Test one is failing because myVar equal 9 as you decrement it twice
Test two is failing as the line you were instructed to change is still there untouched
Please have a look at the comments. That’s what your current code is doing. I won’t be giving you the answer straight away. See if you can figure out your error. Please ignore, if you have already solved it.
var myVar = 11; //Initiates the variable myVar with a value of 11
// Only change code below this line
myVar = myVar - 1; //Subtracts 1 from myVar and updates myVar. Hence the value of myVar now is 10
var myVar = 10; //Initializes myVar to 10 again. Previous value(which was 10) is now lost
myVar--; //This is equivalent to subtracting 1 and updating myVar. I am not going into pre and post decrement concepts. Now the value of myVar is 9.
myVar = 10; //Updates myVar to 10 again. Previous value(which was 9) is now lost
var myVar--; //This is a syntax error. var is a keyword you use to initlalize a variable and myVar-- is a decrement operation. You shouldn't be using var here.