How does the code below work to output 16? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

How does the code below work to output 16?

for(i=4;i<8;i++) { if(i==6) { continue; } sum+=i; } alert(sum);

22nd Jun 2019, 7:08 PM
eMBee
eMBee - avatar
3 Answers
+ 6
First : i=4 and the condition is i less than 8 which is true so i next is 5 then 6 will be skipped cause of if ...continue then 7 then end cause 8 is not less than 8 .the alert for the sum so 4+5+7 .
22nd Jun 2019, 7:19 PM
**🇦🇪|🇦🇪**
**🇦🇪|🇦🇪** - avatar
+ 6
4 + 5 + 7 == 16.
22nd Jun 2019, 7:10 PM
Diego
Diego - avatar
+ 3
6 is not added due to the continue statement.
24th Jun 2019, 7:43 AM
Sonic
Sonic - avatar