0

Break and Continue Topic

var sum=0; for(i=4; i<8; i++) { if (i == 6) { continue; } sum += i; } document.write(sum); output:-16. Explain how the o/p will be 16?

6th Mar 2019, 6:07 PM
Arshad Shaik
Arshad Shaik - avatar
1 Respuesta
+ 3
i=4 then i is minor to 8 i is not equal to 6 then sum=4, becasue 0=0+4 -> sum=4 i=5 then i is minor to 8 i is not equal to 6 then sum=9, becasue 4=4+5 -> sum=9 i=6 then i is minor to 8 i is equal to 6 then jum to end the for i=7 then i is minor to 8 i is not equal to 6 then sum=9, becasue 9=9+7 -> sum=16 i=8 then i is not minor to 8, but is equal the the for is end, and the output is 16 for sum
6th Mar 2019, 6:31 PM
Sudarshan Rai
Sudarshan Rai - avatar