Skip to content

Instantly share code, notes, and snippets.

@BigWillie
Last active October 13, 2015 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BigWillie/4220915 to your computer and use it in GitHub Desktop.
Save BigWillie/4220915 to your computer and use it in GitHub Desktop.
Fizz buzz boom! - Robs fizz buzz answer
// Robs Fizz Buzz with a boom!... with long winded if statements :)
// Try it here: http://eloquentjavascript.net/paper.html
var f = "Fizz",
b = "Buzz";
for (i = 1; i <= 101; i++)
{
if (i%3 == 0 && i%5 == 0) {
console.log(f + b);
} else if (i%3 == 0) { // if there is no remainder, then i is divisible by 3
console.log(f);
} else if (i%5 == 0) {
console.log(b);
} else {
if(i >= 100) {
console.log("BOOM!");
}else{
console.log(i);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment