JS Basic Tutorial
while
Loop:The while
loop executes as long as the specified condition evaluates to true
. The condition is evaluated before the code block executes.
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.
do { // Code to execute } while (condition);