We should have a randomInt method that returns an integer greater than or equal to min and less than max.
function randomInt(min, max) {
if (arguments.length < 2) max = min, min = 0;
min = Math.floor(min);
max = Math.floor(max) - min;
return () => Math.floor(min + Math.random() * max);
}