Get random number in javascript

Math.random() returns a random number between 0 (inclusive) and 1 (exclusive):

Math.random()

the next function return a random integer number between min and max.

function randomInteger(min, max) {
  return Math.floor(Math.random() * (max - min)) + min;