Please help for this exercise

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

After doing this exercise , i got the answer right but the running test came up with this result, what can i do to solve it?
// running tests

myArray

should equal

[5, 4, 3, 2, 1, 0]

. // tests completed // console output [ 0, 1, 2, 3, 4 ] [ 0, 1, 2, 3, 4 ]

  **Your code so far**

// Setup
const myArray = [];

// Only change code below this line

var i = 0;

while (i < 5 ) {
myArray.push(i);
i++;
}

console.log(myArray);
  **Your browser information:**

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

Challenge: Iterate with JavaScript While Loops

Link to the challenge:

In what way do you think you got this right?

The instructions say:

Add the numbers 5 through 0 (inclusive) in descending order to myArray using a while loop.

The test message says:

myArray should equal [5, 4, 3, 2, 1, 0].

Your code outputs:

[ 0, 1, 2, 3, 4 ]

Do you see the problem?

1 Like

It was my misunderstanding , But i have fix it now , Your explanation really helps thanks for that.

1 Like