+ 4
Could someone explain me how this code works line to line? Thanks.
k=6; for(var i=0;i<k;i++){ k+=0.5; } alert(i);
4 ответов
+ 6
Output is 6.
In loop:
i=0
it increases until
i=5
Out of loop:
i will become 6
+ 5
Muhd Khairul Amirin Bin Yaacob you are wrong
+ 4
Rastislav Romanec Zdar, k se ti po celém běhu sesčítá na 12. (k+=0.5). Tím pádem dostaneš for loop
for (var i=0; i<12;i++){
console.log(i); // vypíše hodnoty 0 až 11
}
console.log(i); //má nyní hodnotu 12, protože je mimo loop
+ 1
But, i have got output 12 from this code.