+ 1

Help me to understand why it is printing 16; JavaScript

var sum=0; for(i=4; i<8; i++) { if (i == 6) { continue; } sum += i; } document.write(sum);

8th May 2021, 12:48 PM
Mohammed Salman
2 odpowiedzi
+ 6
1st case i=4 then sum=4 2nd case i=5 then sum=9 3rd case i=6 continue statement used control jumps up. 4th case i=7 then sum=9+7=16 5th case i=8 not possible..so it returns the sum.
8th May 2021, 12:52 PM
Aditya
Aditya - avatar
+ 1
Thanks 😊 Aditya
8th May 2021, 8:15 PM
Mohammed Salman