Javascript examples for Array Operation:Array Element
Assigning x amount of random numbers to an array
<html> <head></head> <body> <script> function getDistinctNumbers(count) { var values = [];/* w ww . j a v a 2 s . co m*/ for (var i=1; i<=64; i++) values.push(i); values.sort(function(a,b){return Math.round(Math.random() * 2) -1;}); values.length = count; return values; } console.log(getDistinctNumbers(24)); console.log(getDistinctNumbers(24)); </script> </body> </html>