Skip to content

anaURL/JavaScript-snippets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

JavaScript-snippets

JavaScript Snippets

// Returns a random number between min (inclusive) and max (exclusive)

const getRandomNumber = (min, max) => Math.random() * (max - min) + min;

getRandomNumber(2, 10)

 // Returns a random number between min (inclusive) and max (inclusive)

const getRandomNumberInclusive =(min, max)=> {
    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min + 1)) + min;
}

getRandomNumberInclusive(2, 10);

About

Short JavaScript code snippets

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published