+ 2
loop in javascript
I want someone to explain this for(i=0;i<10;++i){ i+=2 console.log(i) }
4 Answers
+ 3
i = 0
i += 2 =>i=2
prints 2
++i ; //i=3
3 < 10 true
i += 2 // i=5
prints 5
++i ; //i=6
6 < 10 true
i += 2 //i=8
prints 8
++i ; //i=9
9 < 10 true
i += 2 //i=11
prints 11
++i ; // i=12
12 < 10 false , stops loop
Hope it helps..
+ 3
Jayakrishnaš®š³ Many thanks I understood
0
for(i=0;i<=10;i=i+1){console.log(i)}
i=0;while(i<=10){console.log(i);i=i+1}