Skip to content

Instantly share code, notes, and snippets.

Created May 9, 2013 17:37
Show Gist options
  • Save anonymous/5549120 to your computer and use it in GitHub Desktop.
Save anonymous/5549120 to your computer and use it in GitHub Desktop.
Had to write my own version before before I ask other people to do the same. http://c2.com/cgi/wiki?FizzBuzzTest
var fizzBuzz = function fizzBuzz () {
"use strict";
var fizzArray = [];
var fizzNumCheck = function fizzNumCheck (num) {
var numString = num.toString();
var mult3 = false;
var mult5 = false;
if (num % 3 === 0) {
numString = "Fizz";
mult3 = true;
}
if (num % 5 === 0) {
numString = "Buzz";
mult5 = true;
}
if (mult3 === true && mult5 === true) {
numString = "FizzBuzz";
}
return numString;
};
for (var i = 0; i < 100; i++) {
fizzArray[i] = fizzNumCheck(i+1);
}
console.log(fizzArray);
};
fizzBuzz();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment