Skip to content

Instantly share code, notes, and snippets.

@zanedeg
Created January 24, 2016 00:35
Show Gist options
  • Save zanedeg/2e9f4937b54819f9567f to your computer and use it in GitHub Desktop.
Save zanedeg/2e9f4937b54819f9567f to your computer and use it in GitHub Desktop.
FizzBuzz without loops and only ternary operators
function fizzbuzz(str, next) {
var iterVal = next % 3 === 0 ? 'Fizz' : '';
iterVal += next % 5 === 0 ? 'Buzz' : '';
str += iterVal ? iterVal : next;
return next > 99 ? str : fizzbuzz(str + ',', next + 1);
}
console.log(fizzbuzz("",1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment