I don't know what went wrong. Please can anyone explain?

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

  **Your code so far**
// Setup
const myArray = [];
// Only change code below this line
let i = 6;
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/103.0.5060.53 Safari/537.36

Challenge: Iterate with JavaScript While Loops

Link to the challenge:

This loop executes while i < 6 (less than 6) and you have let i = 6;

okay. Then what can I do to correct it?

what’s the first value you want your i to be, and what’s the last value?

I want it to be i = 5

is that the first or the last value?

It is the first value.

And what should be the last value?

I think it’s like zero (0).

So you need to start at the first value you want, that will be the starting value you give toi

And then you need a loop that will be entered wit that value, and stop once your final value is reached

You need the right condition that will be true for 5,4,3,2,1,0 but not true for lower numbers

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