Created
May 9, 2013 17:37
-
-
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
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 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