For Loop

Domain Hosting image
Web Hosting
Dedicated server
ssl certificate
Web Design image
Email
A for loop uses a variable, which is, updated each time an iteration is made. The for is executed until the variable reaches a value. The syntax for the for loop is:

for(initialexpression ; condition ; incrementexpression){
set of statements
}

The initial expression is executed only once at the start of the loop, which assigns a value to a variable. The second part of the for loop is the condition which is checked for each iteration The condition must remain true to keep the loop running. The final part of the for loop is used to increment the counter. The following example illustrates the use of the for loop.

<html>
<head>
<title>Loops</title>
</head>

<body>
<script Language="JavaScript">
<!--
document.bgColor="aqua"
document.write("<h2>"+ 'TheFor Loop" +" <h2>")
for(i=1;i<7;i++){

j=2*i;
document.write(j+"<br>")}
//-->
</script>
</body>
</html>



Domain Name Search

www.


Copyright (C) 2007. Web Domain design hosting. All rights reserved.