+ 4
What is the output of this code and WHY ?
var sum=0; for(i=4; i<8; i++) { if (i == 6) { continue; } sum += i; } document.write(sum); I DONT UNDERSTAND WHY THE OUTPUT OF THIS CODE IS 16, CAN ANYONE EXPLAIN ME THAT ? THANK YOU SO MUCH !!
3 Answers
+ 16
for loop will be execute till the range that means it execute till 7
4<8 so sum=4+0=4
5<8 so sum=4+5=9
6 came in if block and continue the loop again with next incremented value 7
7<8 so sum=9+7=16
so output is 16
+ 12
yeah
+ 4
thank you, so when there is the CONTINUE statement, the code comes back a the starter loop and goes on.