js array of random numbers code example
Example 1: how do you make a random array in javascript
const Coins = ["Heads","Tails"]
let Generate = Math.floor((Math.random() * Coins.length));
console.log(Coins[Generate])
Example 2: javascript generate array of random different numbers
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);
Example 3: generate an array of random numbers javascript
let numbersArray = [] , max = 100;
for( var i=1; numbersArray.push(i++) < max;);