1
00:00:00,120 --> 00:00:07,140
The do while loop is a variation of the while loop a do while loop will always execute the entire code

2
00:00:07,140 --> 00:00:13,230
block once before checking if a condition is met if the condition is met.

3
00:00:13,310 --> 00:00:19,910
After the first pass it will then loop the code block as long as the condition remains true.

4
00:00:19,910 --> 00:00:24,680
Let's take a look at an example to illustrate this on this page.

5
00:00:24,770 --> 00:00:32,130
We have a javascript function that's executed when a button is clicked we can see the on click event

6
00:00:32,370 --> 00:00:41,770
in our button element that triggers the function named my function the function in our javascript tag

7
00:00:43,170 --> 00:00:50,820
starts with defining a variable named ie with initial value of 0.

8
00:00:50,890 --> 00:00:59,360
Then we have the syntax for our do while loop this loop will start by outputting the value of IE in

9
00:00:59,370 --> 00:01:01,960
incrementing it by 1.

10
00:01:01,980 --> 00:01:10,610
It will continue to loop and increment as long as the value of AI is less than 10 we can see this condition

11
00:01:10,610 --> 00:01:13,970
defined in our while parameter.

12
00:01:14,030 --> 00:01:15,890
Let's click the button to see the result

13
00:01:18,910 --> 00:01:26,780
we can see the loop started zero because that's the initial value of AI the value of AIs then incremented

14
00:01:30,410 --> 00:01:37,880
it is incremented until the value of AI reaches 9 which is less than 10.

15
00:01:37,880 --> 00:01:43,850
Now let's see what would happen if we were to change the initial value of AI to eleven.

16
00:01:44,090 --> 00:01:47,630
We can see that the output is now eleven.

17
00:01:47,630 --> 00:01:55,700
This is because the loop executed once but it does not execute again because this condition is no longer

18
00:01:55,700 --> 00:01:56,110
met.

19
00:01:56,150 --> 00:01:57,380
After the first past.
