Mélanger un tableau :
const s = "123456789"; //string
const t = Array.from(s,s => Number(s)); //String transform tab
// Array.from({length: 9}, (v, k) => k);
function shuffle(){
for (let i=t.length-1 ; i > 1 ; i--){
let nb = Math.floor(Math.random() * i);
//swap
let v = t[nb];
t[nb] = t[i];
t[i] = v;
}
}
//test
while (t[0]< 5){
shuffle();
console.log(t);
}