Breaking News
yeni film izle hd film seyret film izle

do – while Looping In Java Script

This loop continues while the given condition is found true else the loop gets terminated, the difference in this and while looping is even the condition is false but this loop gets executed at least once but while loop gets terminated at initial level if condition is not satisfying.
 
syntax:
 
do

{

code to be executed

}

While (condition )

 
Example
 
</head>

<body>

<script type=”text/javascript”>

var a=1;

do

{

document.write(” “+a);

a+=2

}

while(a<20)

</script>

</body>

</html>

 
Understanding program :
Value of a is initially 1 , the condition with loop is while a is less than 20 the statements typed should be executed. a+=2 means a=a+2, so the a will get incremented with 2 every time. As soon as a becomes 20the loop gets terminated.
 
Output:
1 3 5 7 9 11 13 15 17 19

Check Also

Recursive Functions In Java Script

A function which calls itself, is called a recursive function. When A function calls itself …