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

20 divided by 3 is 6 with remainder 2.

`%`

.`var x = 7 % 2;`

var 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

`onesDigit`

that takes a natural number and returns the ones digit of that number. `onesDigit(2674)`

should return `4`

.
+ Hint

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

+ Solution

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