Skip to content

Instantly share code, notes, and snippets.

@alexymik
Created June 25, 2015 22:26
Show Gist options
  • Save alexymik/61575d115f3c72507a88 to your computer and use it in GitHub Desktop.
Save alexymik/61575d115f3c72507a88 to your computer and use it in GitHub Desktop.
JavaScript FizzBuzz
var fizz_buzz = function(count) {
for (var i = 1; i <= count; i++) {
var output = i;
var fizz = false;
if (i % 3 == 0) {
output = 'Fizz';
fizz = true;
}
if (i % 5 == 0) {
if (fizz) {
output += 'Buzz'
} else {
output = 'Buzz'
}
}
console.log(output);
}
};
fizz_buzz(1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment