Last active
November 10, 2015 04:27
-
-
Save zulhfreelancer/1130ce59c3e7950aa790 to your computer and use it in GitHub Desktop.
FizzBuzz Challenge Solution (Javascript) - Demo: https://jsfiddle.net/kLdwncym/
This file contains hidden or 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
<div id="resultSection"></div> |
This file contains hidden or 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 result = ""; | |
for (i = 1; i < 101; i++) { | |
if (([i] % 3 == 0) && ([i] % 5 == 0)) { | |
result += "FizzBuzz<br>" | |
} else if ([i] % 5 == 0) { | |
result += "Buzz<br>" | |
} else if ([i] % 3 == 0) { | |
result += "Fizz<br>" | |
} else { | |
result += [i] + "<br>" | |
} | |
} | |
document.getElementById('resultSection').innerHTML = result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment