How did we come to this answer | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

How did we come to this answer

var x = 0; for (; x <= 20; x += 2) { document.write(x); } Why is this 2? (; x += 2)

19th May 2017, 11:27 PM
Mark Anthony
Mark Anthony - avatar
1 Answer
+ 12
var x = 0; for ( ; x <= 20; x += 2 ) { document.write(x); } ------------------------------ Q. Why is this 2 ( x += 2 ) A. 2 is the increment, there is no needed of explanation, 2 is simply the increment of x variable. The loop will prints the 2's multiple, it will ends to 20! ------------------------------ Please use an appropriate syntax, your code is too confusing.
19th May 2017, 11:45 PM
Maz
Maz - avatar