Created
October 27, 2013 09:34
-
-
Save richardpilgrim/7179651 to your computer and use it in GitHub Desktop.
Fizzbuzz in Javascript.
I made it to keep myself entertained.
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
<html> | |
<head> | |
<title>FizzBuzz</title> | |
</head> | |
<body> | |
<div id="test"></div> | |
<script> | |
var div = document.getElementById('test'); | |
for(var i=1;i<=100;i++) | |
{ | |
if(i % 3 == 0) | |
{ | |
div.innerHTML = div.innerHTML + 'Fizz'; | |
} | |
if(i % 5 == 0) | |
{ | |
div.innerHTML = div.innerHTML + 'Buzz'; | |
} | |
if(i % 5 != 0 && i % 3 != 0) | |
{ | |
div.innerHTML = div.innerHTML + i; | |
} | |
div.innerHTML = div.innerHTML + '<p>'; | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I could be wrong (and am picking at semantics anyway) but on line 28 shouldn't that be a
rather than a
? Either way - it's good to see a fizzbuzz solution that is actually understandable :)