Last active
October 8, 2021 09:55
-
-
Save mathieueveillard/65301ed3e0144d52282fbcead914dffd 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 isMultipleOf = (m: number) => (n: number): boolean => n % m === 0; | |
export function internal(n: number): string { | |
let result = ""; | |
if (isMultipleOf(3)(n)) { | |
result += "Fizz"; | |
} | |
if (isMultipleOf(5)(n)) { | |
result += "Buzz"; | |
} | |
return result || n.toString(); | |
} | |
export function FizzBuzz(n: number): string[] { | |
return [...Array(n)].map((_, i) => i + 1).map(internal); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment