Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
function* random(min, max, breaking) {
while (true) {
let n = parseInt((Math.random() * max) + min);
if (n === breaking) {
return n;
yield n;
let generator = random(0, 10, 5);
for (let value of generator) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment