0
Why the answer is 16? I donât get it.
I can not understand why the answer is 16, can someone explain please?
5 Answers
+ 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". đ
+ 3
Thank you very much guys ;)
+ 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 đ
+ 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