Here’s how to get the factorial of a number in JavaScript:
function factorial(num) {
if (num < 0) return -1
if (num === 0) return 1
return num * factorial(num - 1)
}
Here’s how to get the factorial of a number in JavaScript:
function factorial(num) {
if (num < 0) return -1
if (num === 0) return 1
return num * factorial(num - 1)
}