The browser storage localStorage is not available. Either your browser does not support it or you have disabled it or the maximum memory size is exceeded. Without localStorage your solutions will not be stored.

# do...while loop

The

`do...while`

loop works similarly to the `while`

loop.
The loop code is executed as long as the loop condition results in `true`

.
The only difference is that the loop condition is checked after the loop code.
This ensures that the loop code is run through at least once.
```
let threeX = '';
do {
threeX = threeX + 'x';
} while (threeX.length < 3);
```

After the loop `threeX`

has the value `'xxx'`

.## Exercise

Write a function

Example:

`lcm`

that takes two natural numbers and calculates their
least common multiple (lcm).
The lcm of two natural numbers a und b is the smallest natural number that is divisible by a and b.Example:

`lcm(4, 6)`

should return `12`

.
+ Hint

To calculate the lcm of a and b, take

`1`

and test whether it is divisible by a and b.
If so, `1`

is the lcm. If not, take `2`

and test again. And so forth.
+ Solution

```
function lcm(a, b) {
let theLCM = 0;
let remainderA;
let remainderB;
do {
theLCM++;
remainderA = theLCM % a;
remainderB = theLCM % b;
} while (remainderA !== 0 || remainderB !== 0)
return theLCM;
}
```