• Archives

  • AddThis Social Bookmark Button

    Add to Technorati Favorites

  • Upcoming Conferences

    • no upcoming events
  • For Loop in javascript

    By krates | November 5, 2007

    Looping is an essential part of programming you can use looping structure to loop through arrays , variables , etc

    Using it

    <html>

    <head>

    <title>Easytutorial.info for loop in javascript</title>

    </head>

    <body>

    <script type=”text/javascript”>

    var r = 10

    for(i=0;i<=r;i++)

    {

    document.write(“Welcome to easytutorial.info <br>”)

    }

    </script>

    </body>

    </html>

    the above script will print 10 times

    welcome to easytutorial.info


    for(i=0;i<=r;i++)

    understand the above statement

    for (i=0 <!– Assigning 0 to i

    ; <!– Sepration Operator –>

    i < = r <! — Condition –>

    i++ <!– Incrementation –>

    { <!– Inside this bracket the code will be executed>  }

    Share and Enjoy:
    • Digg
    • del.icio.us
    • Facebook
    • NewsVine
    • Reddit
    • StumbleUpon
    • YahooMyWeb
    • Google Bookmarks
    • Yahoo! Buzz
    • TwitThis
    • Live
    • LinkedIn
    • Pownce
    • MySpace

    Topics: Javascript | 3 Comments »

    Related Links:

    3 Responses to “For Loop in javascript”

    1. Adino Says:
      November 5th, 2007 at 2:04 am

      Hi! You got a great start to your blog here. Javascript tips are always useful to the thousands of people learning web programming.

      One suggestion: you might want to properly indent your Javascript for better readability.

      for(i=0;i<=r;i++) {
      document.write(”Welcome to easytutorial.info ”);
      }

      You could also consider using different colors to separate HTML and Javascript for even clearer understanding.

    2. Adino Says:
      November 5th, 2007 at 2:05 am

      My suggestions for indentation didn’t display properly. Maybe you could try it between tags or something

      :P

    3. Adino Says:
      November 5th, 2007 at 2:06 am

      …between “pre” tags…