Looking to create an array of unique random numbers in ES6 without any repeats.
Currently, my function is generating an array of random numbers that are repeating:
winArray = [...Array(6)].map(() => Math.floor(Math.random() * 53));
Here is a non-ES6 solution that I came across: Non-ES6 solution
The solution using Set is not working within 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));
}