0
I don't understand why the answer is 5
While b-- goes until b=1 or b = 0 https://code.sololearn.com/WnIycVP5ayBI/?ref=app
4 Réponses
+ 3
while(3)
//b=2
a=3
while(2)
//b=1
a=4
while(1)
//b=0
a=5
+ 2
Heidi Eigner
while loop will work until b becomes 0 and at the same time a will be increase by 1 so here b will be decrement by 1 and a will be increment by 1 so when b becomes 0, a becomes 5.
+ 1
You may find it helpful to output a and b on each iteration to see what's going on
while(b--) {++a; console.log(a + ", " + b);};
0
This is perfect. Thanks