You likely modified the array (like deleting an element) without adjusting the counter backwards, or you accidentally incremented the counter twice in one pass.
How to Properly Increment or Decrement in Loops
Why did my loop skip an element?
The answer
More FAQs in How to Properly Increment or Decrement in Loops
It is the post-increment operator. It increases the value of the variable i by exactly 1.
Initialize the loop variable at the highest index (like array.length - 1), set the condition to i >= 0, and use i-- to decrement.
Yes. You can use i += 2 to skip every other element, or any mathematical operation like i *= 2 for exponential leaps.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.