0
what is output of the code? var sum=o for(i=4;<8;i++){ if (i ==6){ continue } sum+=1 } document write (sum;) ...............?
3 Answers
+ 7
Ignoring the numerous synthax errors, it would print 3.
+ 3
Pls check your Syntax and to complete Zen's correct answer here is an explanation:
var sum = 0;
for(var i = 4 ; i < 8 ; i++) {
if (i == 6) {
continue; //'continue' steps over one iteration
//therefore var 'sum' is raised by one when
//var 'i's value is 4,5 or 7 (example specific)
//8 won't be reached obviously
}
sum += 1; //I'd use: sum++; But it wont matter.
}
document.write(sum); //output is 3
0
There is mistake!