Last active
May 14, 2018 10:42
-
-
Save sramam/8ebd2f7f737656f4f4f794a594dd275b to your computer and use it in GitHub Desktop.
fizzbizz
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
/** | |
A fizzbizz implementation in modern JavaScript | |
*/ | |
const fizzbizz = (n) => { | |
const fz = (n) => { | |
switch(true) { | |
case (n%15 === 0): return 'fizzbizz'; | |
case (n%5 === 0): return 'bizz'; | |
case (n%3 === 0): return 'fizz'; | |
default: return `${n}`; | |
} | |
} | |
console.log(`${n}: ${fz(n)}`); | |
} | |
[...Array(100)].forEach((el, idx) => fizzbizz(idx)); | |
// (new Array(100)).map((el, idx) => fizzbizz(idx)); | |
// for(let n=0; n<=100; n++) { | |
// fizzbizz(n) | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment