Created
January 24, 2016 00:35
-
-
Save zanedeg/2e9f4937b54819f9567f to your computer and use it in GitHub Desktop.
FizzBuzz without loops and only ternary operators
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
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