'Can you help me I want to print the value of factorial 4 but the following function is always giving NAN why?

My question is about recursive function why it is showing always NAN instead of showing the value of factorial 4.

function factorial(i){
              if (i == 1) { return;}  
              return i * factorial(--i);};        
      console.log(factorial(4));


Solution 1:[1]

function factorial(i){
              if (i == 1) { return 1;}  
              return i * factorial(--i);};        
      console.log(factorial(4));

That right.

Solution 2:[2]

if (i == 1) { return;} you should return a number here like return 1;

function factorial(i){
              if (i == 1) { return 1;}  
              return i * factorial(--i);};        
      console.log(factorial(4));

small version of code:

const fact = (num) => num ==1 ? 1 : num * fact(--num);

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 Halone
Solution 2 lusc