Created
May 29, 2018 21:30
-
-
Save topheman/26839181f7091efa2c4a0f9419536841 to your computer and use it in GitHub Desktop.
JavaScript Implementation of FizzBuzz in functional programming
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
// http://wiki.c2.com/?FizzBuzzTest | |
const result = Array.from(Array(100), (_, i) => i + 1).map(number => { | |
if (number%5 === 0 && number%3 === 0) { | |
return "FizzBuzz"; | |
} | |
if (number%3 === 0) { | |
return "Fizz"; | |
} | |
if (number%5 === 0) { | |
return "Buzz"; | |
} | |
return number; | |
}); | |
console.log(result.join('\n')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What about this?