+ 2

How to generate non-repeating random numbers in javascript?

Generating non-repeating random numbers.

7th Nov 2017, 7:15 PM
Okonji Justin
Okonji Justin - avatar
3 Antworten
+ 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
8th Nov 2017, 6:01 AM
DAB
DAB - avatar
+ 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
20th Dec 2017, 5:10 PM
Вадим Сухотин (Vadim Sukhotin)
Вадим Сухотин (Vadim Sukhotin) - avatar
+ 1
This works but it's a bit long 😅 https://code.sololearn.com/WJ3O3UGPFzmG/?ref=app
4th Sep 2020, 2:37 PM
Philip
Philip - avatar