JSFiddle - React, Tailwind, and code Playground

HTML

<input type="button" id="foo" value="rand" />
<p id ="res">

</p>

JavaScript

$(function(){
var base=[0,1,2,3];
var myarr=[0,1,2,3];

function tirage(){
al=myarr.length-1;
if (al== -1) {
alert("array vide");
myarr=myarr.concat(base);
$("#res").empty();
return false;
}
idx=Math.floor(al*Math.random());
console.log(idx)
$('#res').append( myarr[idx]+'<br/>');
myarr.splice(idx , 1);
}


$('#foo').on('click',tirage )

})