Adscend

Click Here



Click Here

Monday

While Loop

While Loop

While loop is used to execute a set of statements repeatedly until a condition becomes false. The loop executes round and round while the condition is true. When the condition becomes false, the loop breaks out or terminates of the loop.
Syntax:
while(condition)
{
// statements that will be executed
}

Example

<script type="text/javascript">

var i=0;
while (i<=4)
{
document.write("The value of i is :"+i+ "<br />");
i++;
}

</script>

Output


You can write the following code and result will be same.
{
document.write("The number is " +i);
document.write("<br />")
i++;
}




No comments:

Post a Comment