Why is this not working?..h

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

  **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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36

Challenge: Iterate with JavaScript While Loops

Link to the challenge:

The failing test says:

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

Your code yields:

console.log(myArray);
// [ 0, 1, 2, 3, 4 ]

Are you asking why you can’t pass or are you asking why the test doesn’t pass or are you asking why what you wrote isn’t doing what you want it to do?

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