JSFiddle - React, Tailwind, and code Playground

by Matthew Vasallo

JavaScript

// Create a computeFactorialNonRecursive method
// The factorial is computed by multiplying all the preceeding numbers together


const computeFactorialNonRecursive = num => {
 let result = 1;
 for (let i=1; i<=num; i++) {
   if(i > 1) {
    result = result * i;
   } 
 }
 return result;
};

console.log(computeFactorialNonRecursive(4));