for (var i = 10; i < 41; i+2) {
console.log(i);
}
I am learning basic javascript and when I ran this on chrome, it crahsed. I think the loop going infinite but I don't understand why.
But when I change i + 2
to i++
, it works fine.
I am trying to print out even numbers between 10 and 40 that's why I changed i + 2
to i++
.
Am I not allowed to make i
increment by 2?