Streaming live at 10am (PST)

Randomization custom code WITHOUT repeats

At the moment, I have some code to pick one random object from an array and it works well. However, I don’t want any repeats in the output. I want to randomly provide a new page link from CMS on the click of a button, and it should be different every time (until of course we run out of objects in the array). What code can I add to this to prevent any repetition?

Here’s the sample code:

<script>
var links = ["page-1",
             "page-2",
             "page-3",
                ...
             "page-108",
              ]

		function openSite() {
				var randIdx = Math.random() * links.length;
        randIdx = parseInt(randIdx, 10);
        var link = 'https://websitename.com/page/' + links[randIdx];
        window.location.assign(link);
        
    };
</script>