do {

console.log(x);

x++;

}

while(x < 10);

As you can see, in a do/while loop, the do statement comes first, therefore is always run at least once. This loop works exactly as the name suggests: the code will do (execute) the block of code inside curly braces, while the condition is TRUE.

As you can probably tell by now, all of these loops are very similar, with minor differences between them. Each has their own specific use-case, but generally you are most likely to be making use of the for loop. Now, let’s write some loops.