Basic JavaScript: Iterate with JavaScript While Loops

Exercise URL -

I am passing the lesson but not sure if I am doing something completely different or if my code is truly correct LOL!!!

Here is my code solution:

var myArray = [];
// Only change code below this line.

var myArray = [0,1,2,3,4];

while(myArray <= 5) {

This is wrong. You are directly creating an array with the elements 0 to 4.

Your while loop doesn’t run, because the condition myArray <= 5 is false.

You are using a varibale i inside your loop that was never declared.

You could either declare a counter, like let i = 0, then use the counter value as a way to run the loops. Maybe while (i < 5) { do something; i++; }.
Or you could use the array.length property to run the loop. while (myArray.length < 5) myArray.push(myArray.length);

Should work…

This works. Thanks you!

var myArray = [0,1,2,3,4]

var i = (0,1,2,3,4);

while(i < 4) {myArray.push(0);i++;}

Do you have a question about this?

What should this do in your opinion?