Breaking News
yeni film izle hd film seyret film izle

while Loop In Java Script

This loop continues while the given condition is found true else the loop gets terminated. The variablemeets the condition at the gate of while loop if the variable do not fulfill the condition then the loop will not be executed for even a single time.
 
syntax:
 
While (condition )

{

code to be executed

}

 
Example
 
<html>

<head>

</head>

<body>

<script type=”text/JavaScript”>

var a=0;

while(a<10)

{

document.write(“\t “+a); a++

}

</script>

</body>

</html>

 
Understanding program :
value of a is initially 0, the condition with loop is while a is less than 10 the statements typed should be executed. a++ means a=a+1, so the a will get incremented with 1 every time. As soon as a becomes 10 the loop gets terminated.
 
Output:
0 1 2 3 4 5 6 7 8 9

Check Also

Recursive Functions In Java Script

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