
A while loop runs as long as its condition remains true. Use it when you don't know in advance how many times the loop needs to run. Always make sure the condition will eventually become false — an infinite loop will freeze the browser. A do...while loop runs the body at least once before checking the condition.
Reference:
TaskLoco™ — The Sticky Note GOAT