0
JS while... do... question
Why will this loop run only once? To me, it should do 10 times... x=0; do{ x++; }while(x>=10);
2 Answers
+ 8
x never goes above 2
your condition says while x is greater or equal to 10
x starts as 0
the loop is executed once, incrementing x to 1 and then exits when the condition is not met
+ 1
yes. of course. it's so obvious. while executes as long as it's true. here it's never true and that's what confused me. thanks.