In Association with Amazon.in   Flipkart

Saturday, August 10, 2013

JavaScript While Loop Example

Example:

<body>
    <script>


    t=9;
    i=1;


    while(i<=12)
    {
        document.write("<br/>" + t+ " X " + i + " = " + i*t);   
        i++;
    }
   
    </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...