JSFiddle - React, Tailwind, and code Playground

by jcutrell

HTML

<button>Add Unique Random</button>
<div class="show"></div>

JavaScript

var pool = [];
var range = 5;
var log = $(".show");
function uniqueRandomChoice(){
    var choice = Math.floor(Math.random() * range);
    if ($.inArray(choice, pool) > -1){
        if (pool.length == range){
            pool = [];
            log.append("<br>");
        }
        uniqueRandomChoice();
    } else {
        pool.push(choice);
        // show the video based on var choice
        log.append(choice);
    }
}
$("button").click(uniqueRandomChoice);