April 21, 2009

0 JavaScript For Loop

Loops in JavaScript are used to execute the same block of code a specified number of times or while a specified condition is true.

The for Loop

The for loop is used when you know in advance how many times the script should run.

Syntax

for (var=startvalue;var<=endvalue;var=var+increment)
{
code to be executed
}

Example

<html>
<head>
<script type="text/javascript">
var i=0
for (i=0; i<=10; i++)
{
document.write ("The number is " + 1)
document.write (" <br />")
}
</script>
</body>
</html>


0 comments:

Post a Comment

Blogger Themes

 
Powered by Blogger