I have array has row's sizes that i need and pick up randomly like this
const Numbers = ["8", "4", "6", "2"];
const randomNumber = Numbers[Math.floor(Math.random() * Numbers.length)];
console.log(randomNumber)this will give me a random value from the array
Now what i want to do is pick 3 numbers sum of them is 12 and after that it reset and start again.
Example:
Random array picked number 8 after that the number should be 4 OR number 2 twice then start all over again
picked number 4 so the available numbers should be 4 twice OR 2 four times OR 4 once and 2 twice ...etc and so on
so the sum should be 12 then reset again
of course all this will be inside loop but what i want to know is the best way to do this.
Aucun commentaire:
Enregistrer un commentaire