Solved: random number 0 to 3

The main problem with random number 0 to 3 is that it is not truly random. This means that the numbers are not completely unpredictable, and can be predicted by someone who knows the pattern.


Math.floor(Math.random() * 4);

This code line is generating a random number between 0 and 3.

Examples with random function

var random = function() { return Math.random(); }; //Returns a number between 0 and 1

Related posts:

Leave a Comment