Created
February 4, 2014 18:02
-
-
Save trikitrok/44bc6e27a92cc6dff1ad to your computer and use it in GitHub Desktop.
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
var fizzbuzz = function (numbers) { | |
var fizzbuzz_one = function (number) { | |
var res = ""; | |
if (number % 3 == 0) | |
res += "Fizz"; | |
if (number % 5 == 0) | |
res += "Buzz"; | |
if (res == "") | |
res = String(number); | |
return res; | |
}; | |
return (function f(acc, rest) { | |
if (rest.length == 0) | |
return acc; | |
else if (rest.length == 1) | |
return acc + fizzbuzz_one(rest[0]); | |
else | |
return f (acc + fizzbuzz_one(rest[0]) + " ", rest.slice(1)); | |
})("", numbers); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment