I think the Javascript code below works like this:
i = 0 first time around.
i = 3 second time.
i = 6 third time.
i = 9 end of loop.
So the loop should run 3 times, but in Google Chrome it becomes an infinite loop. Is there something I'm missing? (complete beginner)
for (var i = 0; i < 9; i + 3) {
console.log('hey');
}
Another detail: I've been using visual studio code live server.
I've experimented with different variations and get the same problem.
One variation:
for (var i = 0; i < 10; i + 2) {
console.log('hey');
}
i + 3
doesn't change i
. You probably meant i += 3
.