Iterate with JavaScript For Loops
Summary
- The
for
loop runs a section of code for a certain number of times. for (a; b; c)
, wherea
is the intialization statement,b
is the condition statement, andc
is the final expression.
Final Code
// Setup
var myArray = [];
// Only change code below this line
for (var i = 1; i <= 5; i++) {
myArray.push(i);
}