JSFiddle - React, Tailwind, and code Playground
JavaScript
function test() {
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
var n = Math.floor((Math.random() * 15));
var tex;
while ((tex = $.inArray(n, arr)) != -1) {
n = Math.floor((Math.random() * 15));
}
return n;
}
alert(test());