0

why the output 6 i`m not understanding

var x = 0; while(x<6) { x++; } document.write(x);

17th Oct 2016, 2:57 AM
Mohamed Ali
Mohamed Ali - avatar
2 Answers
+ 2
Loop after loop, x is incremented by 1. When x is 5, 5 is lower than 6, so we enter the loop yet again, in which x is incremented to 6. Then we exit the loop because 6 is not lower than 6, and we print 6.
17th Oct 2016, 9:02 AM
Zen
Zen - avatar
0
i hate life
11th Dec 2018, 1:31 PM
kristina
kristina - avatar