Iterate with JavaScript Do...While Loops - Help

Why won’t the below be accepted, not sure how this is wrong?

Change the while loop in the code to a do...while loop so the loop will push only the number 10 to myArray , and i will be equal to 11 when your code has finished running.

var myArray = [];
var i = 10;

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

This isn’t the syntax for a do while loop.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/do...while

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.