Skip to content

Instantly share code, notes, and snippets.

@tracker1
Created December 11, 2014 19:40
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 tracker1/d58fa1f83ab17d37eb2c to your computer and use it in GitHub Desktop.
Save tracker1/d58fa1f83ab17d37eb2c to your computer and use it in GitHub Desktop.
Fizz Buzz - JavaScript
function fb(num) {
var fizz = !(num % 3) ? 'Fizz' : ''
,buzz = !(num % 5) ? 'Buzz' : '';
return fizz + buzz || num;
}
for (var i=1; i<101; i++) console.log(fb(i));
for(var n=1;n<101;n++){var f=!(n%3)?"Fizz":"",b=!(n%5)?"Buzz":"";console.log(f+b||n)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment