Code Editor

for loop backwards

If we can make a for loop run forwards through an array, can we make it run backwards through it? Of course!

We can make out loop run backwards by modifying the start, stop, and iterator conditions.

To do this, we'll need to edit the code between the for loop's parentheses:

  1. The start condition should set i to the length of the array.

  2. The stop condition should end when i is 0.

  3. The iterator should subtract 1 each time, which is done with i--.

Community Forums
Get help and ask questions in the Codecademy Forums
Report a Bug
If you see a bug or any other issue with this page, please report it here.