for loops | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

for loops

Hi everyone, pls why is the output of this loop 10? var x = 2; for(i = 0; i < 4; i++) { x += 2; } document.write(x);

28th May 2021, 3:03 PM
Lara
Lara - avatar
2 Answers
28th May 2021, 3:28 PM
JaScript
JaScript - avatar
+ 2
Thank you :)
28th May 2021, 3:43 PM
Lara
Lara - avatar