Iterate with JavaScript For Loops?

Tell us what’s happening:

I thought the solution is the same as the example above it except it should use <= to include 5. What am I missing?

Your code so far


// Example
var ourArray = [];

for (var i = 0; i < 5; i++) {
  ourArray.push(i);
}

// Setup
var myArray = [];

// Only change code below this line.
for (var i = 0; i <= 5; i++) {
  myArray.push(i);
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-for-loops

Read the directions again. You’re initializing the index to zero, but that may not be what you, in fact, want.

The example goes from zero to four, they want YOURS to go from one to five.

Read the instructions: the array should include 1 thru 5. how would you do that with your for loop?

Read the instructions carefully:

Use a for loop to work to push the values 1 through 5 onto myArray .

Felt for a moment like I was sniping on eBay, back in the day. :wink:

Well, I think it’s fair to say that the point was made. :smiley: