To get started I've added an empty unordered HTML list to the page. This is where the where the content on the array of going to be output as part of the example, just to make it visual on the page:<ul class="list"></ul>
With this for loop, instead of incrementing the value of i by adding one each time, we're subtracting. So with the length being 5, we first must first subtract 1, before we can increment i by one less each time with i-- with i being greater than or equal to zero. Now I'm sorry if that's a little confusing, I wrote this section a few times, but couldn't think of a better way of explaining what's happening.
If you can explain this better than I have, please leave a comment below and i'll rephrase it.
But to see how it all works together check out the CodePen example below. This probably explains it better than the paragraph above because you can experiment with it and check out for yourself what's going on:
See the Pen Reverse JS Loops by html5andblog ( @html5andblog ) on CodePen .