I have a function that generates random numbers given a range I want to make sure I don't re-generate the same pair of numbers.
function generateRandomInt(max) {
return Math.floor(Math.random() * Math.floor(max));
}
let randomInt1 = generateRandomInt(10) + 1;
let randomInt2 = generateRandomInt(10) + 1;
let numberStore = randomInt1 + "" + randomInt2;
console.log(randomInt1);
console.log(randomInt2);
console.log(parseInt(numberStore));
numberStore
contains the result of randomInt1
and randomInt2
I want to avoid having a pair of numbers that were already generated.
https://codepen.io/anon/pen/wRJrrW
Aucun commentaire:
Enregistrer un commentaire