0

Conditionals and Loops: Break & Continue

Why does this code output 16? var sum=0; for(i=4; i<8; i++) { if (i == 6) { continue; } sum += i; } document.write(sum);

10th Sep 2018, 3:54 PM
Perl Writer
Perl Writer - avatar
1 Antwort
+ 3
Because in the loop the step i = 6 is skipped with continue statement. So the sum = 4 + 5 + 7 = 16.
10th Sep 2018, 4:10 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar