< JavaScript < Reserved words
The code
The do keyword
The do … while statements executes a loop until the condition in the while statement is reached.
Examples
var array = [2, 3, 5, 7, 10, 11], i = 0, result = 1;
do {
result += array[i++];
if (result%2 == 0) {
continue;
} else if (result > 20) {
break;
} else {
console.log("result = " + result);
}
} while (i < array.length)
returns the following:
result = 3 result = 11
See also
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.