The do while loop is a variation of the while loop a do while loop will always execute the entire code
block once before checking if a condition is met if the condition is met.
After the first pass it will then loop the code block as long as the condition remains true.
Let's take a look at an example to illustrate this on this page.
We have a javascript function that's executed when a button is clicked we can see the on click event
in our button element that triggers the function named my function the function in our javascript tag
starts with defining a variable named ie with initial value of 0.
Then we have the syntax for our do while loop this loop will start by outputting the value of IE in
incrementing it by 1.
It will continue to loop and increment as long as the value of AI is less than 10 we can see this condition
defined in our while parameter.
Let's click the button to see the result
we can see the loop started zero because that's the initial value of AI the value of AIs then incremented
it is incremented until the value of AI reaches 9 which is less than 10.
Now let's see what would happen if we were to change the initial value of AI to eleven.
We can see that the output is now eleven.
This is because the loop executed once but it does not execute again because this condition is no longer
met.
After the first past.