yicr
12/31/2019 - 1:40 PM

JS : Tips / Generating random whole numbers.

var max = 22;
var min = 3;
var randomNumber = Math.floor(Math.random() * (max - min + 1)) + min;

when minimum rumber is 0

var randomNumber = Math.floor(Math.random() * (max + 1));