Learn to be a detective. On a most basic level, when things aren’t working for me, I start logging things out:
while(i > 0) {
console.log('entering while block, pushing i, i =', i)
myArray.push(i);
i--;
console.log('leaving while block, i =', i)
}
console.log(myArray)
What is the condition that tells the while loop that it should stop looping? What does it see on each pass? What happens after that condition is met? What will be the value of i on the start of the last iteration of the loop?
I put those log statements in there so you could see what was happening.