Advertisement
Google Ad Slot: content-top
JS while and do while
while Loop:
The while loop executes as long as the specified condition evaluates to true. The condition is evaluated before the code block executes.
Syntax:
while (condition) {
// Code to execute
}
do...while Loop:
The do...while loop executes the code block at least once, regardless of the condition. The condition is evaluated after the code block executes.
Syntax:
do {
// Code to execute
} while (condition);