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;
if (al== 0) {
alert("array vide");
myarr=myarr.concat(base);
$("#res").empty();
return false;
}
myarr.shuffle();
$('#res').append(myarr.pop() + "<br/>")
}
Array.prototype.shuffle= function () {
var i = 0
, j = 0
, temp = null
for (i = this.length - 1; i > 0; i -= 1) {
j = Math.floor(Math.random() * (i + 1))
temp = this[i]
this[i] = this[j]
this[j] = temp
}
}
$('#foo').on('click',tirage )
})