- 5
var x = 0while( x<6 ){x++;}document.write( x )How is the answer of this is 6?
17 ответов
+ 10
The loop works and when it reaches x=5 it gets incremented to 6 it again checks while loop which is false and the current value of x gets printed.... If u wanna c all value put the write method inside the loop.
+ 3
the loop is 6 time executed, in the last time x became 6!
+ 2
the variable x is incremented to 6 and then further goes up an check the condition, as 6<6 is false so it will jump out of the loop with the final value of x equalize to 6 .
+ 2
x value is overrided until the loop ends. the final value to overrride is 6.
+ 1
The loop is executed 6 times from 0-5.
Until 6 < 6
+ 1
the loop start with x=0 that causes to 6 time.
0
The loop works and when it reaches x=5 it gets incremented to 6 it again checks while loop which is false and the current value of x gets printed
0
The loop's 6 time Execute. when x=5. Check and gets increment 6. then check Again 6<6 loop false. print current value 6
0
6
0
6
- 1
answer is 6 because increment occurs after checking the condition
- 1
The scope of while loop is getting over and after that we are doing document. Write(x) so it will come 6
- 1
6 ok.
- 1
012345
- 1
Answer: 6
- 1
What is the output of this code? var x = 0; while(x<6) { x++; } document.write(x); 6