+ 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 Answers
+ 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.