Increment rule inconsistencies
Problem 1 What is the output of this code? var x = 9; var y = x++; alert (++x * y); Sololearn says the answer is 99. I got 90 because I was under the impression that in the 2nd line, y = 9 and x = 9 since x++ is a post fix increment. So by the 3rd line (++x made 10 for me since the value didn't change from the 2nd line). --------- Problem 2 What will be alerted? n = 2; m = (n++ * 12); alert(m); Sololearn says the answer is 24. The increment rules are inconsistent with the answers to both these questions. How come in the first question we add the +1 to get 10 in the second line then add +1 again to get 11, but in the next question we don't add the +1, even though in both questions they're both post fix increments ? I hope I'm not confusing anyone. But I'll try to explain clearer if it's too confusing.