Login

Unique random number in Javascript

Get Unique random numbers

In order to get unique random numbers in array. First we need to get random number using (Math.random()*parseInt(max)).toFixed(0);.
We have the push the value into an array...
For getting second random number we need to get random number and then we have to check whether the number is exist in the array or not. If it is not in the array then we can push it into the array.
Here the code