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.

# Modulo

Another arithmetic operator is modulo. It calculates the remainder of a division and is represented by

`%`

.
```
let x = 7 % 2;
let y = 20 % 3;
```

7 divided by 2 is 3 with remainder 1. `x`

is `1`

.
20 divided by 3 is 6 with remainder 2. `y`

is `2`

.## Exercise

Write a function

Example:

`onesDigit`

that takes a natural number and returns the ones digit of that number.Example:

`onesDigit(2674)`

should return `4`

.
+ Hint

```
function onesDigit(n) {
// Use modulo 10.
}
```

+ Solution

```
function onesDigit(n) {
return n % 10;
}
```