const fizzBuzz = (until) => { const fizz = ["Fizz", "", ""]; const buzz = ["Buzz", "", "", "", ""]; (function fizzybuzzy(current) { console.log(fizz[current % 3] + buzz[current % 5] || current); return (current + 1 <= until) && fizzybuzzy(current + 1); })(0); } fizzBuzz(100);
Some improvement to my earlier version.
A) better (arguably, because way more cognitive load than the very simple one above)
const fizzBuzz = (until, current = 0, fizzbuzz = ["", "Fizz", "Buzz"]) => { const fizzybuzzy = () => fizzbuzz[!(current % 3) * 1] + fizzbuzz[!(current % 5) * 2] || current; return (current + 1 <= until) && (console.log(fizzybuzzy()), fizzBuzz(until, current + 1)); } fizzBuzz(100);
B) above one as 1 liner b/c hello perl
const devBuzz = (function i(u, c= 0, m=["", "dev", ".to"]) {(c+1<=u) && (console.log(m[!(c % 3)*1] + m[!(c%5)*2] || c), i(u,c+1));}); devBuzz(20);
Also thinking about overriding Number.prototype.toString makes a fun thingy. Maybe someone already did, but someone for sure should :D
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.
Some improvement to my earlier version.
A) better (arguably, because way more cognitive load than the very simple one above)
B) above one as 1 liner b/c hello perl
Also thinking about overriding Number.prototype.toString makes a fun thingy. Maybe someone already did, but someone for sure should :D