+ 2
How to generate non-repeating random numbers in javascript?
Generating non-repeating random numbers.
3 Réponses
+ 3
Store the random numbers in an array
If the new random number is equal to any previous random number stored in the array, don't print it to the screen
+ 1
I would advise not to store it in an array, but in an associative array that is done through an object. In this case, the verification of the presence of the computed number is made easier, without a cycle: by one operation in.
https://code.sololearn.com/WaFH4sVitUf9
+ 1
This works but it's a bit long 😅
https://code.sololearn.com/WJ3O3UGPFzmG/?ref=app