Add the numbers 5 through 0 (inclusive) in descending order to myArray using a while loop.
The code you have, which is the example, start from 0 and increment i as long as the value is less than 5.
Which is working and valid, but not what the challenge is asking you to do.
Try adding console.log(myArray); to the end of your code. See what logs to the console and compare it with what myArray should be. (myArray should equal [5,4,3,2,1,0].)
The stuff inside the while loop will execute if i<=0. However, the line before that you said i=5. 5 is greater than 0 so the while loop will never execute.
think: you want the loop to execute when i is 0 because you want to have also the 0 in the array. Right now the condition is false when i is 0, you need to make the condition true for when i is 0
I been working on and off this code since. And now the website wants to timeout and have to reload. Which gets annoying. Is this supposed to happen when executing this? Its annoying.
Do not use = (equal) in any for, while, do while loop. Example (while i =< 5). Why? when i = 5 it becomes infinite. Yeah, you might have i++ but why trust that? What if you then have i--?. Infinite! Do the process mentally and see what I mean: "If i = 5 then" what?
…unless, of course, you have an escape plan like break after a conditional if or switch statement, which can complicate matters the more.
BACK in the good 'ole days we had to force shutdown (power off) our computers or applications when we got stuck in an infinite loop.