Last active
July 26, 2020 20:48
-
-
Save wazazaby/3668a8b6b55940dee475316d41a357f5 to your computer and use it in GitHub Desktop.
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
const fizzbuzz = number => { | |
const isFizz = number => number % 5 === 0; | |
const isBuzz = number => number % 3 === 0; | |
const genIterable = number => [...Array(number).keys()].map(i => i + 1); | |
const verification = number => { | |
if (isFizz(number) && isBuzz(number)) return 'fizzbuzz'; | |
if (isFizz(number)) return 'fizz'; | |
if (isBuzz(number)) return 'buzz'; | |
return number | |
}; | |
return genIterable(number) | |
.map(verification) | |
.join('\n'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment