Ad

eval style

Code
Diff
  • calculator=(a,b,_)=>eval(a+_+b)
    • calculator=(a,b,_)=>_=='+'?a+b:_=='-'?a-b:_=='*'?a*b:_=='/'?a/b:undefined
    • calculator=(a,b,_)=>eval(a+_+b)

eval style

Code
Diff
  • digit_sum = x => eval([...''+(x>0?x:-x)].join`+`)
    
    • digit_sum = x => (x+'').match(/\d/g).reduce((a, e) => a + +e, 0);
    • digit_sum = x => eval([...''+(x>0?x:-x)].join`+`)