save up to 40%

How to run loops?

Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.

How to run loops?

Rating:

Loops are a set of statements that run a statement or a set of statements several times until the given condition is true. If the condition becomes false, the execution of the loop stops and the control is passed on to the next statement.

There are three kinds of loops in JavaScript, which are as follows:

  1. The for loop: The syntax of the for loop is as follows:


  2. for(initialization;condition;increment/decrement)
    {
           //statements
    }


    The following is an example of running the for loop:

    for(x=0;x<10;x++)
    {
           document.write(x)
    }


  3. The while loop: The syntax of the while loop is as follows:


  4. while(condition)
    {
           //statements
    }


    The following is an example of running the while loop:

    while(x<10)
    {
           document.write(x)
           x++
    }


  5. The do-while loop: The syntax of the do-while loop is as follows:


  6. do
    {
           //statements
    }while(condition)


    The following is an example of running the do-while loop:

    do
    {
           document.write(x)
           x++
    }while(x<10)


Rating:



Other articles

Click here to Article home

 
uCertify.com | Our Company | Articles | Privacy | Security | Contact Us | News and Press Release | uCertify India
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD Cisco Certification: CCNA, CCENT, A+, Network+, Security+
Oracle Certification: OCP 9i, OCP 10g, OCA 9i, OCA 10g CIW foundation    EC-212-32    CISSP    Photoshop ACE    Adobe Flash ACE
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.