You can still have flow control with functions.
const troo = (iff, elz) => iff; const falz = (iff, elz) => elz; const choose = (value) => [falz, troo][Number(Boolean(value))]; const is_fizz = (n) => choose(n % 3 === 0); const is_buzz = (n) => choose(n % 5 === 0); const fizzbuzz = (n) => is_fizz(n) ( () => is_buzz (n) ("FizzBuzz", "Fizz"), () => is_buzz (n) ("Buzz", n), ) .call(); const range = (end) => new Array(end).fill(null).map((val, index) => index + 1); range(15).map(fizzbuzz).join(", ");
I liked this approach! Thanks for sharing!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You can still have flow control with functions.
I liked this approach! Thanks for sharing!