Previous Topic: The while loop StatementNext Topic: The for Loop Statement


The do/while Loop Statement

The do-while loop has the following syntax:

do
	statement
while (Boolean_expression);

The do-while loop is similar to the while loop except that it tests at the bottom of the loop rather than at the start of the loop. The while loop performs a sequence of statements as long as the Boolean expression returns a True value. For example:

var n = 0
do {
	Process.square[n] = n * n
} while (n++ < 10)