function getRandomInt(max) {
    // Return random integer from 0 to max-1
    return Math.floor(Math.random() * max);
}


function getRandomIntForInterval(min, max) {
    // Return random integer from min to max-1
    return Math.floor(Math.random() * (max - min + 1) + min);
}

function shuffle(array) {
    for (let i = array.length - 1; i > 0; i--) {
        const j = Math.floor(Math.random() * (i + 1));
        [array[i], array[j]] = [array[j], array[i]];
    }
}

function getShuffledArray(array) {
    // Pure function that returns a shuffled version of "array".
    // The original array is unmodified.
    let shuffledArray = [... array];
    shuffle(shuffledArray);
    return shuffledArray;
}

export {getRandomInt, getRandomIntForInterval, shuffle, getShuffledArray};