+ 2
Question on Javascript
What is the output of this code? var x = 0; while(x<6) { x++; } document.write(x);
2 Answers
+ 12
6
+ 3
As Vukan said, it'll be 6. Your condition stops the loop if it's 6 or greater. The statement inside of your loop is only increasing X by one, thus the moment it becomes 6 the loop isn't going to run again, leaving X with a value of 6.