Iterate with JavaScript Do...While Loops 1

Tell us what’s happening:

What could be wrong here ?

Your code so far


// Setup
var myArray = [];
var i = 10;

// Only change code below this line.
do {
myArray.push(i);
i++;
while (i < 10); 
}

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-do---while-loops

You forgot your closing bracket } before while

Yeah i have given the } after while , But still doesn’t work

i starts at 10, and your while loop now says: hey computer as long as i is smaller than 10, do this. But i is already 10. (the second line of code states it).

so only change your while part and then everything is okay. =)

So are you saying , i should code while

while (i < 10); and everything will be fine ?

No not after but before, like this:

do {
myArray.push(i);
i++;
} while (i < 10);

thanks , got it. i would have known.