javascript Program to create function that returns factorial of given number code example
Example 1: factorial javascript function
function factorialize(num) {
if(num < 2) return 1;
return num *= factorialize(num - 1);
}
Example 2: how to make a factorial function in javascript
function factorialize(num) {
var result = num;
if (num === 0 || num === 1)
return 1;
while (num > 1) {
num--;
result *= num;
}
return result;
}