fisher123.com JavaScript Loops

LOOPS!

For Loop

Used to run a group of code statements repeatedly by setting a series of parameters that have to be true for the looping to stop. Usually FOR loops are used when you know how many times you want a loop to run. Here is a basic for Loop format:

<script language="javascript">

for (i=1; 1<=5; i=i+1)

{
Some JavaScript Event
}

click here for more about for loops

While Loop

Also used to run JavaScript repeatedly as long as a condition has not been met. Usually loops are used when you do not know how many times the script will loop. Here is a simple while loop:

<script language="javascript">

var loops=input from a prompt or other method

var num=1

while (num <= loops)

{
JavaScript Event
}

</script>

click here for more about while loops