Basic JS: Iterate with JavaScript While Loops

Hi all

Appears the aim of this one has been updated since solutions have been posted / help vid was produced - tapping in this (given as solution - both hint & vid; produces ascending as opposed to descending…see final post):

var i = 0;

while(i < 5) {

myArray.push(i);

i++;

}

Which is as per anything I can find help-wise…but as its requesting it should have 5 through 0 descending (above produces ascending)…

Assume Im missing summat obvs…apols in advance if so!

Example is intended to show you how while loop works and now your challenge is to figure out what initial value of i should be and what’s gonna be the stopping condition for the loop as well as how i variable shall be modified in order to solve the given problem.

If I teach you how to drive around the block I presume you would be able to drive elsewhere, right? Not just around same block. ))

The example was the given answer as per solutions provided…not sure what Im to write to have it go descending.

As @snigo said: The video is just an example/walkthrough of the skills described in the lesson.

If you would like a hint, click on the Get a Hint button…

Hope this helps

Aye sorted - just the hint links to a thread from back in 2016 which was quoting the same solution…hence why I wasnt getting overly experimental with it!

But aye - in the bag it is :slight_smile: - much obliged

var i = 5;

while(i>-1){

myArray.push(i);

i–;

}