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);
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 .
+ 6
4 + 5 + 7 == 16.
+ 3
6 is not added due to the continue statement.