Link Search Menu Expand Document

Iterate with JavaScript For Loops

Summary

  • The for loop runs a section of code for a certain number of times.
  • for (a; b; c), where a is the intialization statement, b is the condition statement, and c 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);
}