Ad
Recursion
Mathematics

One line ternary

Code
Diff
  • const fibonacci = n => n <= 1 ?  n : fibonacci(n - 1) + fibonacci(n - 2)
    • function fibonacci(n) {
    • if (n <= 1) return n;
    • return fibonacci(n - 1) + fibonacci(n - 2);
    • }
    • const fibonacci = n => n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2)