Last active
December 16, 2021 20:38
-
-
Save goshki/484945 to your computer and use it in GitHub Desktop.
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
// Prints to browser console (Chrome, Firefox), no explicit ifs. Starts from 1. | |
for(i=0;i++<100;console.log([['fizz'][i%3],['buzz'][i%5]].join('')||i)); // 72 characters | |
// Writes to array 'a', no explicit ifs. Starts from 1. | |
for(a,i=0;i<100;a[i++]=([['fizz'][i%3],['buzz'][i%5]].join('')||i)); // 68 characters | |
// Returns an array (Firefox only), no explicit ifs, no explicit loops. Starts from 0. | |
Array.apply([],Array(100)).map((e,i)=>[['fizz'][i%3],['buzz'][i%5]].join('')||i) // 80 characters |
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( i ) { | |
return [ [ 'fizz' ][i%3], [ 'buzz' ][i%5] ].join( '' ) || i; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for(i=0;i<100;console.log((++i%3?'':'fizz')+(i%5?'':'buzz')||i)); //66 characters :)