To factorialize a number in JavaScript, use this function:
const factorial = n => n * (n <= 1 ? 1 : factorial(n - 1))
.Here's how you do it:
const factorial = n => n * (n <= 1 ? 1 : factorial(n - 1));
console.log(factorial(1)); // 1
console.log(factorial(2)); // 2
console.log(factorial(5)); // 120
console.log(factorial(10)); // 3628800