Skip to content

Instantly share code, notes, and snippets.

@sranso
Created November 15, 2013 04:50
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 sranso/7479296 to your computer and use it in GitHub Desktop.
Save sranso/7479296 to your computer and use it in GitHub Desktop.
fizzbuzz.js
// prints numbers 1-100
// when the number is divisible by 3, say fizz
// when the number is divisible by 5 say buzz
// when the number is divisible by 3 and 5 say fizzbuzz
for (var i = 1; i <= 100; i++)
{
if (i % 3 == 0 && i % 5 == 0) {console.log("fizzbuzz")}
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