Iterate with JavaScript While Loops, javascript

Tell us what’s happening:
hello guys help,
my code isn’t producing what is expected so I failed to diagnose the problem.

Your code so far


// Setup
var myArray = [];

// Only change code below this line
var i = 5;
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/86.0.4240.198 Safari/537.36.

Challenge: Iterate with JavaScript While Loops

Link to the challenge:

the loop is never entered as 5<5 is false

Thanks for the suggestion but how am I suppose to put the loop such that it produces the required result of[5, 4,3,2,1,0] because I tried many options but it isn’t working.

ooh!
it finally worked when with this code

var i = 5;

while (i >= 0 ){

  myArray.push(i);

  i--

}

you have i starting at 5 and then decreasing - you need a condtion that is true for all the numbers you want in the array, and that become false when you want to stop it

You are using push() to throw numbers at the end of the array, how about replacing push() with something that throws numbers at the beginning of the array?