Created
June 25, 2015 22:26
-
-
Save alexymik/61575d115f3c72507a88 to your computer and use it in GitHub Desktop.
JavaScript FizzBuzz
This file contains 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
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