Created
May 30, 2018 16:56
-
-
Save Oluwasetemi/a5eb585805e4aad569e1f0c6306ef250 to your computer and use it in GitHub Desktop.
FizzBuzz created by Oluwasetemi - https://repl.it/@Oluwasetemi/FizzBuzz
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(amount) { | |
// let arr = [] | |
// for (let i = 0; i <= amount; i++) { | |
// arr.push(i) | |
// } | |
return Array.from({ length: amount + 1 }) | |
.map((v, i)=> i) | |
.filter((v => v !== 0)) | |
.map(v => { | |
if (v % 3 === 0 && v % 5 === 0) { | |
return 'FizzBuzz' | |
} else if (v % 3 === 0) { | |
return 'Fizz' | |
} else if (v % 5 === 0) { | |
return 'Buzz' | |
} | |
return v | |
}) | |
} | |
fizzBuzz(100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment