Skip to content

Instantly share code, notes, and snippets.

@rajatgeekyants
Created June 19, 2018 06:43
Show Gist options
  • Save rajatgeekyants/56038588198187b6973e937ffc5f37aa to your computer and use it in GitHub Desktop.
Save rajatgeekyants/56038588198187b6973e937ffc5f37aa to your computer and use it in GitHub Desktop.
function* numbers() {
let index = 1;
while(true) {
yield index;
index = index + 1;
if (index > 10) {
break;
}
}
}
function rajat() {
for (const num of numbers()) {
console.log(num);
}
}
rajat();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment