do....while constructS2C Home « Statements « do....while

Creates a loop structure.

Description

Creates a loop through a section of code which will be executed at least once.

Syntax

Signature Description
do
   statement
while (condition);
Creates a loop through a section of code which will be executed at least once.

Parameters

Parameter Description
statementExecuted first time through the loop and afterwards while expression evaluates to true.
conditionAn expression that evaluates to true or false and is tested after each pass through the loop.

Examples

The code below shows a do....while loop.


// this loop will execute once.
var bVariable = 11;
do {
  alert('bVariable = ' + bVariable);
  bVariable += 4;
} while (bVariable < 10);
alert('left do....while loop');

Press the button below to action the above code:


Related Tutorials

JavaScript Intermediate Tutorials - Lesson 4 - While and Do....While Loops

go to home page Homepage go to top of page Top