Last active
March 29, 2020 00:18
-
-
Save plugn/ba700dd34fc8d633c77ef218bdd0fe77 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
const range = (min, max) => Array.from(Array(max - min + 1).keys()).map(v => v + min) | |
const fizzBuzz = (max, min = 1) => | |
range(min, max) | |
.reduce((acc, num) => | |
[...acc, ((num % 3 ? '' : 'Fizz') + (num % 5 ? '' : 'Buzz') || num)], | |
[]) | |
.join(', ') | |
// fizzBuzz(18) | |
// 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz, 16, 17, Fizz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment