Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Factorial! factory.
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