Last active
August 29, 2015 14:15
-
-
Save furf/fe2552ad702dd1916583 to your computer and use it in GitHub Desktop.
fizzbuzz
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, s, i) { | |
s = { | |
0: 'FizzBuzz', | |
3: 'Fizz', | |
5: 'Buzz', | |
6: 'Fizz', | |
9: 'Fizz', | |
10: 'Buzz', | |
12: 'Fizz' | |
}; | |
i = 0; | |
while (i++ < n) { | |
console.log(s[i % 15] || i); | |
} | |
} | |
fizzbuzz(100); |
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, i, f, b) { | |
i = 0; | |
while (i++ < n) { | |
f = i % 3 ? '' : 'Fizz'; | |
b = i % 5 ? '' : 'Buzz'; | |
console.log(f || b ? f + b : i); | |
} | |
} | |
fizzbuzz(100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment