Three Ways to Factorialize a Number in JavaScript
Sonya Moisset

I used a for loop with push() and reduce() methods, but now I see how some of these other variations are cleaner… It’s pretty interesting to see how many different pathways one can take to factorialize.

function factorialize(num) {
 var positiveIntegers = [];
 if (num === 0){
 return 1;
 for (var i = 1; i <= num; i++); {
 return positiveIntegers.reduce(function(positiveIntegers, num){
 return positiveIntegers * num;

Like what you read? Give Scott Plunkett a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.