Skip to content

Instantly share code, notes, and snippets.

@nanonanomachine
Created August 11, 2015 01:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanonanomachine/319b10d46c60df0aa24a to your computer and use it in GitHub Desktop.
Save nanonanomachine/319b10d46c60df0aa24a to your computer and use it in GitHub Desktop.
ES6 Generator FizzBuzz
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);
}
@codeBleuz
Copy link

Doesn't work on my machine

@codeBleuz
Copy link

My error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment