Math.random()- Range: 0 ⇐ x < 1
let randomNumber = Math.random() * 6-
Range is 0 ⇐ x < 6
-
With range
function getRandomArbitrary() {
let result = Math.random() * (max - min) + min;
return Math.round(result);
}- Example: 1-13
function getRandomCard() {
return Math.floor(Math.random() * 13) + 1;
}