Basic JavaScript - Iterate with JavaScript Do...While Loops

Tell us what’s happening:
Describe your issue in detail here.
Why is my code showing error? If I remove the code in ‘while’ loop it is getting executed.
Your code so far

// Setup
const myArray = [];
let i = 10;

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

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Iterate with JavaScript Do…While Loops

Link to the challenge:

The syntax of a do…while loop is:

do {
  ... code...
} while (condition);

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