- for
- while
The for Loop :
The for loop is used when you know in advance how many times the script should run. Syntax of for loop is as follow :
for ( variable = startvalue; variable<endvalue;variable = variable + increment)
{
code to be executed
}
For example
for (i=0; i<3; i++)
{
y=y + "The number is " + i + "<br />";
}
This for loop runs 3times, and write results in every new line. The result of above code will be :
The number is 0
The number is 1
The number is 2
No comments:
Post a Comment