show-notice
hide-notice

Wednesday, 7 August 2013

While Loop In Javascript


Introduction:

In JavaScript and most other languages, "loops" enable your program to continuously execute a block of code for a given number of times, or while a given condition is true. The JavaScript While loop executes code while a condition is true. For example, you could make your program display a the value of a counter while the count is less than or equal to say, 10.

Example:
<script type="text/javascript">
<!--
var myBankBalance = 0;

while (myBankBalance <= 10) {
document.write("Right now, my bank balance is $" + myBankBalance + "<br />");
myBankBalance ++;

}

</script>

SHARE THIS POST   

0 comments :

Post a Comment

Design by Gohilinfotech | www.gohilinfotech.blogspot.com