do...while loop - 03

Do … while statements :

In some cases, we want a piece of code to run at least once before checking the condition true or false, we can use do … while loop.


After running the code for the first time, then it will check the specified condition. If the condition evaluates to true, the code block will execute again.


Looping stops when the condition evaluates to false.


Step 1:





Step 2 : 












Step 2 will continue until the condition is false.


Example : 


let ourArray = [];
    let i = 0;
    do {
      ourArray.push(i);
      i++;
    } while (i < 5);


Post a Comment

Previous Post Next Post