0
got confused with JSChallange, decrement in WhileLoop
i got this question where var a; var b = 0; a = 20; a = --a; while(a > a--){ b++; } document.write(b); the result that i got is 0, why? is the 'b' not being processed by the while loop? or its just a trap question? Or is it because a>a-- is 19 > 19 which is returned false so that the looping do not runing thus the 'b' is back to the first value? Am I clear enough to describe my question? I'm afraid you don't understand with what I'm trying to ask
4 odpowiedzi
0
I would assume it's because 19 == 19. Since it's a post decrement, the variable 'a' won't be affected until after, so you got it. It just won't trigger the while loop
+ 1
oh ok i understand now, tysm for your explanation
0
Slick
so its true that the WHILE looping do not asign the b++ to the 'b' because the condition that the WHILE meet is 'false' And the value of 'b' is still 0.
0
Yeah, check this one
https://code.sololearn.com/WyJd9J0D78Ct/?ref=app