Javascript/FOR loop

Discussion in 'Web Design & Programming' started by gumdigger, Mar 19, 2006.

  1. gumdigger

    gumdigger Geek

    Likes Received:
    0
    Trophy Points:
    16
    Hi
    Does anyone here know how to use the FOR loop in javascript
    if yes then can they show me how to write a 20 times table.
     
  2. Addis

    Addis The King

    Likes Received:
    91
    Trophy Points:
    48
    Code:
    <script type="text/javascript">
    var i = 0
    var num = 20
    for (i=1; i <= 10; i++)
    {
    document.write(i + " times 20 is " + num)
    document.write("<br />")
    num = num + 20
    }
    </script>
    
    That'll print them, change the code to suit.
     

Share This Page