NextGen Knowledge Center

do…while loops

These loops let code execute at least once based on a Boolean (true/false) condition. A do...while loop consists of a process symbol and a condition. The code in the block executes, and the condition is evaluated. If the condition is true, the code in the block is executed again, repeating until the condition becomes false. A do…while loop checks the condition after the block is executed, in contrast to the while loop, which tests the condition before the block is executed. It is possible—and sometimes desirable—for the condition to always evaluate as true, which creates an infinite loop. When such a loop is created purposely, there is usually another control structure, such as a break statement, that terminates the loop.

Syntax (do...while loops)Example
do {
    // Code to execute
} while (conditional); 
var index = -1;
do {
    var val = getValue(++index);
} while (val != "ABC");