Ad

arrow function
recursive function
ternary operator

Code
Diff
  • const factorial = (num) => num > 0? num * factorial(num -1): 1;
    
    • function factorial(num){
    • if(num === 1){
    • return 1;
    • }
    • return num * factorial(num - 1)
    • }
    • const factorial = (num) => num > 0? num * factorial(num -1): 1;