Last active
June 24, 2016 21:23
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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