Skip to content

Instantly share code, notes, and snippets.

@federicobucchi
Created September 25, 2014 22:02
Show Gist options
  • Save federicobucchi/882c94755956c108e7ee to your computer and use it in GitHub Desktop.
Save federicobucchi/882c94755956c108e7ee to your computer and use it in GitHub Desktop.
function fizzbuzz(n) {
var n;
var iterations = n;
var result = [];
for (n = 1; n <= iterations; n++) {
if ((n % 3 == 0) && (n % 5 == 0)) {
result.push('FizzBuzz');
} else if (n % 3 == 0) {
result.push('Fizz');
} else if (n % 5 == 0) {
result.push('Buzz');
} else {
result.push(n);
}
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment