I have several Figure objects stored in an array called figureTab, and I'm storing used elements in an array called used.
Do I need to set a random number twice? Objects inside the array
var used = [];
for (let i = 0; i < figureTab.length; i++) {
var random = Math.floor(Math.random() * figureTab.length);
if (used.length == 0) {
used.push(random);
html += "<div>" + (figureTab[random].FigureNr + 1) + "></div>"
}
else{
for (let j = 0; j < used.length; j++) {
if (used[j] == random) {
random = Math.floor(Math.random() * figurTab.length);
j = 0;
}
}
used.push(random);
html += "<div>" + (figureTab[random].FigureNr + 1) + "></div>";
}
document.getElementById("alternatives").innerHTML = html;
.FigureNr?