Confused on what i'm missing

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

// Setup
var myArray = [];

// Only change code below this line
var i = 0;
while(i < 6) {
myArray.push(i);
i++;
}
  **Your browser information:**

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

Challenge: Iterate with JavaScript While Loops

Link to the challenge:

Hi @Kameron !

Welcome to the forum!

If you console.log(myArray) you will see that the output is this [ 0, 1, 2, 3, 4, 5 ]

You will need to reverse the logic of your current code to get the correct output of this [5,4,3,2,1,0]

Your count here should not start at zero
var i = 0;
You will need to change that so it starts at the correct number.
Hint: look at the first part of the FCC instructions again
Add the numbers 5 through 0 (inclusive)

You will need to change this part

So that i is greater than or equal to 0

Lastly,
You will need to change this part

because it makes more sense to decrement than increment for this problem.
FCC instructions:
in descending order

Hope that makes sense.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.