+ 1
What is the output of this code and why?
var i=0; for(; i<12 ;){ i+=2; } console. log(i) It's a JavaScript question
6 odpowiedzi
+ 3
12. In every cycle, i is incremented by two. Penultimate execution of for, it values 10. Still less than 12, for is executed, i evaluates to 12, condition i<12 is no more satisfied, for stops.
+ 3
If this is a quiz question then the quiz is screwed up.
Until you forgot that it is <= and not just plain <
+ 1
Interesting.... Try and console.log() in any cycle
+ 1
I get 12:
var i = 0;
for(;i<12;){
i+=2;
}
console.log(i);
0
answer is 14, I don't know why?
0
Yes, I also got 12 but don't know why