Ad
Code
Diff
  • const removeEveryThird = str => str[0]+[...str].filter((a,i)=> i%3!==0).join('')
    • function removeEveryThird(str) {
    • return (str[0] || '') + str
    • .slice(1)
    • .replace(/(..)./g, '$1')
    • }
    • const removeEveryThird = str => str[0]+[...str].filter((a,i)=> i%3!==0).join('')
Fundamentals
Mathematics
Code
Diff
  • const isDivisible = (a,n) => !(a%n)
    • function isDivisible(a,n){
    • return a%n == 0;
    • }
    • const isDivisible = (a,n) => !(a%n)

A little less parentheses (thanks to de Morgan's law)

Code
Diff
  • const isDivisible = (n,x,y) => !(n%x || n%y)
    • const isDivisible = (n,x,y) => (!(n%x) && !(n%y))
    • const isDivisible = (n,x,y) => !(n%x || n%y)
Code
Diff
  • isEven = num => num%1===0?!(num%2):undefined
    • isEven = num => Number.isInteger(num) ? !(num & 1) : undefined;
    • isEven = num => num%1===0?!(num%2):undefined

Little bit shorter...

Code
Diff
  • const power = (a, b) => a ** b || 1;
    • const power = (a, b) => a === 0 ? 1 : a ** b;
    • const power = (a, b) => a ** b || 1;
Code
Diff
  • var Greet = () => "Hello World!"
     
    
    • function Greet(){return "Hello World!"}
    • var Greet = () => "Hello World!"