4 posts for 'JavaScript'

    Get random number withing a range in JS

    //min - inclusive, max - exclusive
    function getRandom(min, max) {
        return Math.random() * (max - min) + min;
    }
    
    //random integer
    function getRandomInt(min, max) {
        min = Math.ceil(min);
        max = Math.floor(max);
        return Math.floor(Math.random() * (max - min + 1)) + min;
    }
“If you only read the books that everyone else is reading, you can only think what everyone else is thinking.” - Murakami