Am requesting for some help on how the output of this code block is 16, in JavaScript. Please. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Am requesting for some help on how the output of this code block is 16, in JavaScript. Please.

var sum = 0; for (i=4; i<8; i++) { if (i==6) { continue; } sum += i; } document.write(sum);

24th Nov 2021, 9:22 PM
Dwytes CJ ☣☢
Dwytes CJ  ☣☢ - avatar
2 Answers
+ 5
First iteration: i = 4 -> sum = 0+4 = 4 Second iteration: i = 5 -> sum = 4+5 = 9 Third iteration: i = 6 -> continue -> addition is skipped Fourth iteration: i = 7 -> sum = 9+7 = 16 Loop ends.
24th Nov 2021, 9:27 PM
Simon Sauter
Simon Sauter - avatar
+ 3
Please always tag the language you're asking about. https://code.sololearn.com/W3uiji9X28C1/?ref=app
24th Nov 2021, 9:29 PM
Simon Sauter
Simon Sauter - avatar