Return to Kroll Design home page

JavaScript Tutorials

 
« Return

for loop

The "for" statement is a popular method for doing iterative loops.

Make sure that you don't put a semicolon after the right paren:

Wrong: for (i=0; i<10; i++); { /* code goes here */ }
Right: for (i=0; i<10; i++) { /* code goes here */ }

Code:

<script type="text/javascript">
//<![CDATA[
i = 1; for (i=1; i<=10; i++) { document.write(i, "<br>"); } //]]> </script>

Output:



 
« Return


©2012 Kroll Design    info@KrollDesign.net    781.910.3694
Last modified: 12/31/1969 7:00 PM