0
Different value outside loop?
This is one of the JavaScript exercises that I'm unable to understand how the result is 16. Could someone break it down? I also seem to get a different value when placing "document.write" inside the loop. var sum=0; for(i=4; i<8; i++) { if (i == 6) { continue; } sum += i; } document.write(sum);
1 Answer
+ 2
You are adding to sum 4, 5 and 7. The value i == 6 is skipped with "continue". So the result is sum = 4 + 5 + 7 = 16. Hope that my explanation can help you.