Skip to content

Instantly share code, notes, and snippets.

@zulhfreelancer
Last active November 10, 2015 04:27
Show Gist options
  • Save zulhfreelancer/1130ce59c3e7950aa790 to your computer and use it in GitHub Desktop.
Save zulhfreelancer/1130ce59c3e7950aa790 to your computer and use it in GitHub Desktop.
FizzBuzz Challenge Solution (Javascript) - Demo: https://jsfiddle.net/kLdwncym/
<div id="resultSection"></div>
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