I'm trying to generate an array of random numbers in ES6 - numbers should not be repeated.
Currently, my function generates an array of random numbers, but they are repeating:
winArray = [...Array(6)].map(() => Math.floor(Math.random() * 53));
Here is non-ES6 solution that I've found: Non-ES6 solution
This solution with Set is not running in a for-loop:
for (let i = 1; i <= draws; i += 1) {
// Generating a random array of 6 number
const winArray = new Set();
while (winArray.size < 6) winArray.add(Math.floor(Math.random() * 53));
}