jsvascrpit random code example
Example 1: math random equitative js
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
Example 2: js random
Math.floor(Math.random() * 10) + 1 // Random number Between 1 and 10
// First Math.random give us a random number between 0 and 0,99999
// The we multiply it by 10
// And we round dow with Math.floor
// We add 1 so the result will never be 0
// Another Example:
h.floor(Math.random() * 20) + 10 // Random number Between 10 and 20