Ad

Simplified prior code.

Code
Diff
  • function factorial (n) {
      return (n !== 0 && n !== 1) ? (n * factorial(n - 1)) : 1 
    }
    • function factorial (n) {
    • if (n === 0 || n === 1) {
    • return 1;
    • } else {
    • return n * factorial(n - 1);
    • }
    • return (n !== 0 && n !== 1) ? (n * factorial(n - 1)) : 1
    • }