Last active
May 12, 2018 11:21
-
-
Save ulisesantana/d5563cd11f0c925e4d0fe9ea9e26ff19 to your computer and use it in GitHub Desktop.
Fizz Buzz JavaScript Solution
This file contains 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(num) { | |
const isDivisibleBy = x => y => y % x === 0; | |
const isDivisibleBy3 = isDivisibleBy(3); | |
const isDivisibleBy5 = isDivisibleBy(5); | |
return isDivisibleBy3(num) && isDivisibleBy5(num) | |
? 'FizzBuzz' | |
: isDivisibleBy3(num) | |
? 'Fizz' | |
: isDivisibleBy5(num) | |
? 'Buzz' | |
: num; | |
} | |
Array.apply(null,new Array(100)).map((value, index) => { | |
console.log(fizzBuzz(++index)) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment