Okay so, I'm trying to create an application where when you click a button it Generates and Displays a concatenated sequence of unique Numbers between 1 and 76. I have it generating 1 -78 randomly with no dupes but I am unsure as to how I would make it so when it comes to displaying it, it displays 1 number and then increments +1 with every click.
So first click [28] second click [28, 33] and so on without duplicates. here is the code I have so far
window.onload = onclick;
function onclick() {
document.getElementById("BtnCall").onmousedown = GenNumber;
}
function GenNumber() {
var num = LoadNumbers(1, 76);
num = shufflearray(num);
for (i = 0; i < 1; i++) {
ShowArray(num);
}
};
function LoadNumbers(min, max) {
var arr = [];
for (var i = min; i <= max; i++) {
arr.push(i);
}
return arr;
}
function shufflearray(input) {
var out = [];
while (input.length > 0) {
var i = Math.random() * input.length;
var a = input.splice(i, 1);
out.push(a);
}
return out;
}
function ShowArray(m) {
for (var i = 0; i < m.length; i++) {
document.getElementById("usednum").innerHTML += (m[i]+', ');
}
}
Thanks for any support/help :)
needs to behave/like this https://gyazo.com/bebb7c58c402934050be8bc9be29e183
instead of this: This happens with one single click
Aucun commentaire:
Enregistrer un commentaire