I am posting for a friend who found some absolutely mind blowing ideas.
First a one-liner that extends my destructuring idea.
const fn = n => ({ ['2xx0x10xx01x0'[n % 15]]: result = n } = ['Fizz', 'Buzz', 'FizzBuzz'], result);
secondly a solution built around a regex from hell/heaven
let fn = n => String(n).replace(/^(?=.*[05]$)(?:[0369]|[147](?:[0369]|[147][0369]*(?:[258]|[147][0369]*[147]))*(?:[258]|[147][0369]*[147])|[258](?:[258]|[258][0369]*(?:[147]|[258][0369]*[258]))*(?:[147]|[258][0369]*[258]))*$/, 'FizzBuzz').replace(/^(?:[0369]|[147](?:[0369]|[147][0369]*(?:[258]|[147][0369]*[147]))*(?:[258]|[147][0369]*[147])|[258](?:[258]|[258][0369]*(?:[147]|[258][0369]*[258]))*(?:[147]|[258][0369]*[258]))*$/, 'Fizz').replace(/^\d*[05]$/, 'Buzz');
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.
I am posting for a friend who found some absolutely mind blowing ideas.
First a one-liner that extends my destructuring idea.
secondly a solution built around a regex from hell/heaven