Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

generate unique random number in javascript

var arr = [];
while(arr.length < 8){
    var r = Math.floor(Math.random() * 100) + 1;
    if(arr.indexOf(r) === -1) arr.push(r);
}
console.log(arr);
 Run code snippet
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #generate #unique #random #number #javascript
ADD COMMENT
Topic
Name
4+2 =