Skip to content

Instantly share code, notes, and snippets.

@jdfm
Created June 23, 2015 23:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdfm/77915ce05164746dad48 to your computer and use it in GitHub Desktop.
Save jdfm/77915ce05164746dad48 to your computer and use it in GitHub Desktop.
use a for switch block to implement a fizz buzz
for ( var i = 1; i <= 100; i++ ) switch ( true ) {
case !( i % 3 ) && !( i % 5 ): console.log('fizzbuzz', i); break;
case !( i % 3 ): console.log('fizz', i); break;
case !( i % 5 ): console.log('buzz', i); break;
default:
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment