pronoobP
Denoβ€’3y agoβ€’
26 replies
pronoob

Question about for loops

Why does the following code log numbers from 0 to 9 instead of 1 to 9? i is assigned as zero in the first expression, then it checks whether i is less than 10 and moves to the next expression which is i++, so it should increment the value of i to 1 instead and log it
for (let i = 0; i < 10; i++) {
    console.log(i);
}
Was this page helpful?