I will appreciate help on this platform cuz i been on it for a while. i tried all the method i know but wouldnt let me to the next level

Tell us what’s happening:

Your code so far


// Setup
var myArray = [];

// Only change code below this line
var i = 0;
while(i < 5){
myArray.push(i);
i++;
}

console.log(myArray);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36.

Challenge: Iterate with JavaScript While Loops

Link to the challenge:

Well, your code counts up, while the challenge wants you to count down. How could you make your i get smaller instead of bigger?

1 Like

Hi.
You simply need to invert few things in the example given in the lesson.

As a hint, you should start with:

var myArray = [];
var i = 5;
while(i.....) {
  myArray.push(i);
  i....;
}
2 Likes

thanks for sharing, i got it done.

thanks for sharing, i got it done.

1 Like