Last active
July 1, 2019 01:15
-
-
Save kunigami/5132ac24d4fcdf0661cbd24aedf54115 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeGenerator(n) { | |
return { | |
*[Symbol.iterator]() { | |
for(cnt = n - 1; cnt >= 0; cnt--) { | |
yield cnt; | |
} | |
}, | |
}; | |
} | |
it = makeGenerator(30); | |
for (value of it) { | |
console.log(value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment