Created
December 11, 2014 19:40
-
-
Save tracker1/d58fa1f83ab17d37eb2c to your computer and use it in GitHub Desktop.
Fizz Buzz - JavaScript
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 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)); |
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
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