Iterate with JavaScript While Loop omg again?

This line is incorrect : while(i <= 0) {

remove < and replace it with > so it began looping from 5 and stopped at 0 with increment 1.
hopefully this will help to solve your problem.

Here you go, below is your code which will pass the test:

var myArray = [];
var i = 5;
while(i >= 0) {
    myArray.push(i);
    i--;
}
console.log(myArray);
1 Like

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Thank you for understanding.

In this case it has also been 5 months since the question was asked, so the user probably no longer needs help with this question.

1 Like

Really elegant. I like.