+ 3

Issues with for loop!

The excersize says this should provide and even increasement from 0 to 20, the variable goes: var x=20 for (;x <= 20; x += 2 ) { document.write(x) } my question is what is the point of two, it only treat my answer as right when I put 2, why can't it be one for example, it makes more sense?

25th Feb 2017, 8:46 PM
Dunja Cetkovic
Dunja Cetkovic - avatar
3 Answers
+ 5
oooh I see, we don't call them even numbers in my native lanugage so I didn't realise they are called even, they call them "devidable numbers" in my language, thank you so much!!
25th Feb 2017, 9:09 PM
Dunja Cetkovic
Dunja Cetkovic - avatar
+ 2
Incrementing by 1 (× += 1) will print all numbers. Incrementing by 2 (× += 2) will print only the even numbers.
25th Feb 2017, 9:02 PM
Donald Green
Donald Green - avatar
+ 1
uhhh if we want an increment from 0 to 20 then we should start with var x = 0; ?
5th Mar 2017, 5:04 PM
Bamitzdan
Bamitzdan - avatar