First of all we must understand the meaning of factorial:
The factorial function multiply all numbers from our chosen number down to 1.
For instance:
Way of thinking:
function factorial(num) {
if(num <= 0) {
return 1;
} else {
let result = num * factorial(num - 1)
return result;
}
}