'How to find factorial using a function with constraints in JavaScript

I am trying to find the factorial of an integer using a function with the following constraint

1<=N<=10

Below is my code but when I execute it I am receiving NaN! Can you please explain and show me where is my mistake. Much appreciated!

const factorial = function (n) {
  if (n >= 1 && n <= 10) {
    return n * factorial(n - 1);
  }
};

console.log(factorial(5));


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source