The Math random() static method returns a random number between 0 (included) and 1 (excluded)
console.log(Math.random());
// 0.9310115858354047 // will always be different!
// common, more-advanced example - whole number generator
function getRandomNumber(max) {
return Math.floor(Math.random() * max);
}
console.log(getRandomNumber(5));
// 0 - 4 // will always be different whole number