I'm just going through freedcodecamp and I'm doing the "Iterate Odd Numbers With a For Loop" section. I just have a question with regards to some unintended effects I encountered.
const myArray = [];
for (let i = 1; i < 10; i += 2) {
myArray.push(i);
}
This is the correct answer and I got there no problem, however I'm wondering why changing the i += 2
to i + 2
generates an infinite loop?