+ 3
Why does the code below output 6?
var x=0; while(x<6){ x++; } document.write(x);
2 Réponses
+ 6
when x == 5
loop still executes as 5 is smaller than 6
then x becomes 6, loop terminates then as 6 is not smaller than 6
so final value of x after loop is 6
+ 2
thanks!