Created
November 25, 2019 16:41
-
-
Save codebubb/8500d3af842cc6449f209c38b65e4afa to your computer and use it in GitHub Desktop.
FizzBuzz Iterator
This file contains hidden or 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
| const fizzBuzz = { | |
| [Symbol.iterator]() { | |
| let i=0; | |
| return { | |
| next() { | |
| return { done: i++ >= 100, value: i % 15 === 0 ? 'FizzBuzz' : i % 5 === 0 ? 'Buzz' : i % 3 === 0 ? 'Fizz' : i }; | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment