Decrement a Number with JavaScript - Solution

Decrement a Number with JavaScript


let myVar = 11;

// Only change code below this line
myVar = myVar - 1;
myVar = 10;

Hello! Welcome to the community :partying_face:!

First of all, please don’t share the solutions unless you absolutely have to, in which case put the code between a spoiler tag: [spoiler]the code goes here[/spoiler].

Second, even though the solution passes the test, it’s not correct. The lesson asks you to

Change the code to use the -- operator on myVar .

and while you did so, the way you did it is like cheating. The idea is that the final value should be 10 but without setting the variable to the that specific value.


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.