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:

var links = ["page-1",

		function openSite() {
				var randIdx = Math.random() * links.length;
        randIdx = parseInt(randIdx, 10);
        var link = '' + links[randIdx];