In Association with Amazon.in   Flipkart

Saturday, August 10, 2013

Javascript For Loop Example

JavaScript For Loop Example:

 For Loop Syntax

     for(assignment; test condition; Inc/Dec)
    {
        --------;
        --------;   
    }  


Example:

    <body>
     <script>
    t=9;
    for(i=1; i<=12; i++)
    {
        document.write("<br/>" + t+ " X " + i + " = " + i*t);  
    }

   <script>
   <body>


Output:

 
9 X 1 = 9
9 X 2 = 18
9 X 3 = 27
9 X 4 = 36
9 X 5 = 45
9 X 6 = 54
9 X 7 = 63
9 X 8 = 72
9 X 9 = 81
9 X 10 = 90
9 X 11 = 99
9 X 12 = 108

No comments:

Post a Comment


Related Posts Plugin for WordPress, Blogger...