Created
April 30, 2012 20:58
-
-
Save staxmanade/2562639 to your computer and use it in GitHub Desktop.
FizzBuzz - 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
var msg; | |
// FizzBuzz 1 | |
for(var i = 1; i <=100; i++, msg = ''){ | |
if(i % 5 === 0) | |
msg = 'Buzz'; | |
if(i % 3 === 0) | |
msg += 'Fizz'; | |
document.write((msg || i) + '</br>'); | |
} | |
// FizzBuzz 2 | |
for(var i = 1; i <=100; i++, msg = ''){ | |
document.write((((!(i % 5) ? 'Buzz' : '') + (!(i % 3) ? 'Fizz' : '')) || i) + '</br>'); | |
} | |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment