Josh R. answered 01/20/21
Full-Stack Ruby/Javascript Developer
A JavaScript for loop has a few different parts. Let's take a look at those really quick.
The statements between the ( ) are what tells the for loop how to operate. The first statement is
This tells the for loop what variable to use and what its initial value is.
This instructs the for loop to run only under this condition. Our variable i must be less than the length of the object obj.
This mutates the value of our i variable that is then made available inside our next iteration. Here we are simply incrementing our initial i variable by 1. It's worth noting that this last statement is executed after each iteration.
If we execute the following we get our desired output, the individual values inside the variable array.
Simple enough, right?