Basic JavaScript - Iterate with JavaScript While Loops

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

Your code so far

const myArray = [];
let i = 0;

while (i < 5) {
  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/109.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Iterate with JavaScript While Loops

Link to the challenge:

Kindly, the code does not pass, help me to fix the error
Hint: myArray should equal [5, 4, 3, 2, 1, 0] .

Your function is essentially just a copy of the example function, and will return [0, 1, 2, 3, 4, 5].
If you want to return [5, 4, 3, 2, 1, 0], you’ll need to write a function which does the opposite (i.e. starts from 5 and decrements down to 0).

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