returns random integer 1 .. max
from MDN documentation for Math.random
// return random integer 1 .. max function getRandomInt(max) { return Math.floor(Math.random() * max) + 1; }