Skip to content

Instantly share code, notes, and snippets.

@ezy
Last active June 24, 2016 21:23
Show Gist options
  • Save ezy/80ae4f5ef0be852a7f33ab6526992647 to your computer and use it in GitHub Desktop.
Save ezy/80ae4f5ef0be852a7f33ab6526992647 to your computer and use it in GitHub Desktop.
Ezy's fizzbuzz (a.k.a pinocchio's Am I a real boy? test)
function fizzBuzz(n) {
var fizzy = [];
for (var i = 1; i <= n; i++) {
if (i % 3 === 0 && i % 5 === 0) {
fizzy.push("FizzBuzz");
}
else if (i % 3 === 0) {
fizzy.push("Fizz");
}
else if (i % 5 === 0) {
fizzy.push("Buzz");
}
}
console.log(fizzy);
console.log(fizzy.length);
}
fizzBuzz(100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment