DEV Community

Discussion on: Understanding Javascript Array Series V - Array Loops & Iteration Part II

Collapse
 
nedyudombat profile image
Nedy Udombat • Edited

@dovca , I see your point on calling it statements instead of functions, I will correct it to that effect.

The reason for using the .reverse() method was explained in the article, just above that section. Seeing this other approach I will, add that to the article and give due credit.

Setting the index to 1 will not work for the while loop cause at first iteration the value of index will become 1 because of the increment in the condition. However initializing index to -1 will work.

Thank you.