Jump to content

  • Free consultations and support
  • Live chatClick Here for Live Chat
  • Call ico 1888-906-1888
    Phone support: Open

    Ready for your call :)

    Our business hours:

    Mon — Fri, 2am — 8pm (EST)

    US & EU support teams

    Phone support: Closed

    We are back in: 1h 20m

    Our business hours:

    Mon — Fri, 2am — 8pm (EST)

    US & EU support teams

JavaScript While Loop

javascript while loop

  • Please log in to reply

#1 SmartWeb


    Senior Member

  • Designer
  • 271 posts

Posted 27 February 2013 - 02:03 PM

The while loop allows you to repeat things while any conditional statement is true.
A JavaScript while loop consists of two key parts:

1.The conditional statement that has to be True , so that the code of the while loop would be executed.
2.The actual code of the while loop contained in curly braces "{ “ and “ }" that will be executed only if the condition is True.
When the while loop begins, your JavaScript interpreter checks for the condition statement to see if it’s true. If it is true, the code within the curly braces is executed. At the end “}”, the while loop then loops back to the conditional statement and starts gain.

<script type="text/javascript">

while(Counter < 10){
document.write("Counter = " +Counter);

document.write("My While loop is Over!");

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users