How to generate a random array without repetition?
Asked by Sai Siva Kumar about 2 years ago
1
I want to loop an array of numbers, in every iteration random numbers has to be gnerated without repetition
let array=[2,4,8,16,32] for(i=0;i<array.length;i++){ let random=Math.floor(Math.random()*array.length) console.log(array[random] }
1 Answer
0
While filling the number u can check whether its already present in the array or not, if so then dont add it.
show more answers
Your answer