Skip to content

Instantly share code, notes, and snippets.

@marclave
Last active April 11, 2017 05:02
Show Gist options
  • Save marclave/4fad3cdb925a6868cf30a64f71e2c37c to your computer and use it in GitHub Desktop.
Save marclave/4fad3cdb925a6868cf30a64f71e2c37c to your computer and use it in GitHub Desktop.
Array.from({length: 20}, () => Math.floor(Math.random() * 1000));
// Unique
var arr = []
while(arr.length < 20){
var randomnumber = Math.ceil(Math.random()*1000)
if(arr.indexOf(randomnumber) > -1) continue;
arr[arr.length] = randomnumber;
}
console.log(arr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment