+ 1
Please help
var a = 1; for (;a < 5; a++){ a+=a; } alert (a); please explain this code.
3 Answers
+ 5
first: a = 1 < 5 = true // a = 1+1 = 2 then + increment 1 = 3
sec: a = 3 < 5 = true // a = 3+3=6 then + increment 1 = 7
third: a = 7 < 5 = false // code stops
alert(a) // a = 7
+ 1
Ben is right. sorry my bad
0
loop a=1 to 4
do a= old a + new a
effectively, a = 1+2+3+4
alert a i.e. a=10



