Can anyone explain what is happening here?
for (var i = 0; i < 10; i++) {
/* ... */
}
console.log(i);
//expect 9 as loop states i < 10, however it shows 10
I would expect when i is logged that it would show a value of 9. From what I understand is that the loop will run from 0-9 and then will stop as the loop states that i < 10. However, when I console.log(i) it shows 10. Can anyone explain why this is the case?
whileloop and you'll see what is happening