Created
August 11, 2015 01:46
-
-
Save nanonanomachine/319b10d46c60df0aa24a to your computer and use it in GitHub Desktop.
ES6 Generator FizzBuzz
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
let fizzbuzz = function*(){ | |
for (var val = 1; val < 100; val++) { | |
if(val % 15 === 0){ | |
yield "FizzBuzz"; | |
} | |
else if(val % 3 === 0){ | |
yield "Fizz"; | |
} | |
else if(val % 5 === 0){ | |
yield "Buzz"; | |
} | |
yield val; | |
} | |
}(); | |
for (var n of fizzbuzz) { | |
console.log(n); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doesn't work on my machine