Created
September 4, 2016 20:20
-
-
Save jgresalfi/daafbd47b3d403368ce791547b898d29 to your computer and use it in GitHub Desktop.
Factorial! factory.
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
function factorialize(num) { | |
var facArray = []; | |
if (num === 0) { | |
return 1; | |
} else { | |
for (var i = 1; i <= num; i++) { | |
facArray.push(i); | |
} | |
return facArray.reduce(function(a, b) { return a * b; }); | |
} | |
} | |
factorialize(5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment