Skip to content

Instantly share code, notes, and snippets.

@rogeruiz
Created June 22, 2011 23:12
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 rogeruiz/1041516 to your computer and use it in GitHub Desktop.
Save rogeruiz/1041516 to your computer and use it in GitHub Desktop.
JavaScript FizzBuzz
var fizz = "Fizz",
buzz = "Buzz";
for (var i = 1; i <= 100; i++) {
if (i % 3 == 0 && i % 5 == 0) {
console.log(fizz + buzz);
} else if (i % 3 == 0) {
console.log(fizz);
} else if (i % 5 == 0) {
console.log(buzz);
} else {
console.log(i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment