0

Why the answer is 16? I don’t get it.

I can not understand why the answer is 16, can someone explain please?

10th Apr 2021, 10:35 AM
Jen Teller
Jen Teller - avatar
5 Respostas
+ 10
>> i = 4, sum = 0+4 = 4 >> i = 5, sum = 4+5 = 9 >> i = 6, continue (means skip) >> i = 7, sum = 9+7 = 16 >> i = 8, condition is false, break Output: 16 btw, you wrote "vas" instead of "var". 🙂
10th Apr 2021, 10:46 AM
Genuine Stalwart
Genuine Stalwart - avatar
+ 3
Thank you very much guys ;)
10th Apr 2021, 10:49 AM
Jen Teller
Jen Teller - avatar
+ 2
vas sum = 0; for (i = 4; i < 8; i++) { if (i == 6) { continue; } sum +=i; } document.write(sum); The output is 16, and I don’t undestand how 😕
10th Apr 2021, 10:42 AM
Jen Teller
Jen Teller - avatar
+ 2
i=4, sum = 0 + 4 = 4 // loop start i=5, sum = 4 + 5 = 9 skip coz i == 6 // continue i=7, sum = 9 + 7 = 16 answer i = 8, break false // loop end
10th Apr 2021, 12:22 PM
Apongpoh Gilbert
Apongpoh Gilbert - avatar