Skip to content

Instantly share code, notes, and snippets.

@RinatValiullov
Created October 13, 2019 09:37
Show Gist options
  • Save RinatValiullov/57187cd6cc621382a49843f755cef641 to your computer and use it in GitHub Desktop.
Save RinatValiullov/57187cd6cc621382a49843f755cef641 to your computer and use it in GitHub Desktop.
Get pool of random numbers
let generateRandomNumbers = (quantity) => {
let randomValues = {
[Symbol.iterator]: function() {
return {
next: function() {
return { value: ~~(Math.random() * quantity) };
}
}
}
};
return randomValues;
};
let random_pool = [];
for(let item of generateRandomNumbers(100)) {
random_pool.push(item);
if(random_pool.length === 100) { break; }
}
console.log(random_pool);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment