Doubt with Increment a Number with JavaScript

Dear all,
Good afternoons,

I am trying to solve the challenge of the topic: Increment a Number with Javascript,
according to what i read there are 2 ways of solve this problem :

var x = 3;
y = x++; // y = 3, x = 4

var a = 2;
b = ++a; // a = 3, b = 3

This was my code before reading the post :

var myVar;
var myVar=88;
myVar++; (because the challenge asked me to change the following:
myVar = myVar +1 ; )

I was trying and trying to solve that part without sucess and then i read a post of november 2018
and i used the alternative Prefix and it worked but i don´t know when i should use the alternative
postfix and the alternative prefix.

Now my code which is working good is the following

var myVar = 87;

Could anyone please explain me which is the difference between using a postfix alternative and a prefix alternative? and in which cases i can use it?

I will appreciate your kind help :slight_smile:

Kind regards,


**Your browser information:**

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36`.

**Link to the challenge:**

You don’t need to use a pre-increment. I suspect that there was something else going on with your code. What was the full code of your solution that didn’t pass the tests?

Thank you ArielLeslie, i appreciate the help,
I send you 2 pictures attached of my code, and now it seems that
i need to end all the indications to continue studying but i don´t know why
the last part which says don´t change the code above the line does not works good.pregunta4

Thank you in advance :slightly_smiling_face:

Well, you changed line 1 and you also put code above the line that says “do not change code above the line”
It has nothing to do with whether you use ++var or var++.

Dear ArielLeslie,

And do you know if there is any possibility of refresh the page and find it like in the beggining so i can not make the same mistakes? Because i was trying to do it but it continues to carry me to the same page changed with my mistakes.

Instead of refreshing the page, click the button that say “Reset All Code”.

I thank you so much and appreciate your kind help
thank you so much and have a wonderful day dear ArielLeslie,
Kind regards,
Ivonne (it´s nice to meet you)

I’m glad I could help. Happy coding!

Thank you :slightly_smiling_face:
also for you happy coding dear ArielLeslie