JSFiddle - React, Tailwind, and code Playground
HTML
<input type="button" id="button" value="Button" />
JavaScript
var ar = [0,1,2,3,4,5], count = 0, randomNos = {};
$(function(){
no = Math.floor(Math.random()*ar.length);
while(count <= ar.length){
no = Math.floor(Math.random()*ar.length);
if(randomNos[no]){
count++
}
else{
randomNos[no] = 1;
alert(ar[no]);
}
}
/*if(count > ar.length){
count = 0;
randomNos = {}
}
alert(ar[no]);*/
});