0
Why this JS code executing number 16?
var sum=0; for (i=4; i<8; i++) { if (i==6) { continue; } sum +=i; } document.write(sum);
2 odpowiedzi
+ 11
First
Value of i=4
If condition not satisfied
Sum=4
Next
Value of i=5
Condition not satisfied
Sum = (4+5)=9
Next
Value of i=6
Condition satisfied
Continue
Next
Value of i=7
Condition not satisfied
Sum =(9+7)=16
Next
i=8 not less than 8
So loop condition not satisfied it will terminate
Hence sum =16
+ 1
Thank you very much, got it