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;
    }
“Let yourself be silently drawn by the strange pull of what you really love. It will not lead you astray." - Rumi