Answers for "javasciprt random int"

1

js random int

function getRandomInt(min, max) {
    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min + 1)) + min;
}
Posted by: Guest on September-18-2020
0

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
Posted by: Guest on January-04-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language