Ad
Code
Diff
  • const isEven = (num) => {
      if (typeof num === 'number' && Number.isInteger(num)) return num % 2 === 0 ? true : false
    }
    • const isEven=i=>typeof i==="number"&&i!==Infinity&&Math.floor(i)===i?i%2===0:undefined
    • const isEven = (num) => {
    • if (typeof num === 'number' && Number.isInteger(num)) return num % 2 === 0 ? true : false
    • }
Recursion
Mathematics
Code
Diff
  • function fibonacci(n) {
     if (n === 0) return 0;
     if (n === 1) return 1;
     return fibonacci(n - 1) + fibonacci(n - 2);
    }
    • function fibonacci(n) {
    • if (n === 0) {
    • return 0;
    • }
    • if (n === 1) {
    • return 1;
    • }
    • return fibonacci(n - 1) + fibonacci(n - 2);
    • if (n === 0) return 0;
    • if (n === 1) return 1;
    • return fibonacci(n - 1) + fibonacci(n - 2);
    • }