Ad

The factorial of a number is the product of all the numbers from 1 to that number

Like factorial of 3 would be 1 x 2 x 3

function factorial (n) {
  if (n <= 0) return 0
  
  let i = fact = 1
  while (i <= n) { 
  fact *= i
  i++
  }
  return fact
  
}