Generate a random number with JavaScript between 0 and max

//Generate a number between 0 and max…

Math.floor(Math.random() * (MaxValue + 1));

This is for when you know the lowest number will be 0 for the random number. If you want a larger minimum value or its unkown look at Generate a random number snippet

Add your comment