+ 1
Find the result? And why?
first case: var i = 0; while (i < 10) { i = i + 1; } document. write(i); ------------------------- second case: var i = 0; while (i < 10) { document. write(i); i = i + 1; } -------------------------
2 Answers
+ 1
First case: result will be ' i ' (10).
The condition in the will case will be false until the last instruction executed.
Second case: result will be ' i ' ten time cause the write instructions will be executed for (0,1,2,3,4,5,6,7,8,9).
+ 1
This should be posted to your feed.