Ad
Code
Diff
  • const returnInputNumber = n => typeof n === "number" ? n : 0;
    
    • const returnInputNumber = (n = 0) => {
    • return typeof n === "number" ? n : 0;
    • };
    • const returnInputNumber = n => typeof n === "number" ? n : 0;
Code
Diff
  • const formatIfNumber = (v, n) => {
      if (+v === v) return +v.toFixed(n);
      return v;
    };
    • formatIfNumber = (v, n) => +v===v ? +v.toFixed(n) : v
    • const formatIfNumber = (v, n) => {
    • if (+v === v) return +v.toFixed(n);
    • return v;
    • };
Recursion
Mathematics
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);
Code
Diff
  • returnInputNumber = n => typeof n === "number" ? n : 0
    • const returnInputNumber = (n = 0) => {
    • return typeof n === "number" ? n : 0;
    • };
    • returnInputNumber = n => typeof n === "number" ? n : 0
Code
Diff
  • returnhundred = () => 100
    • const returnhundred = () => 100;
    • returnhundred = () => 100
Code
Diff
  • helloWorld = name => `Hello, ${name}.`
    
    • const helloWorld = (name) => `Hello, ${name}.`;
    • helloWorld = name => `Hello, ${name}.`