Area or Perimeter (7/8 kyu)
Codewars (8 prerequisite) 7kyu refactoring to < 39 characters of code
by trentHarlem
HTML
<p>
https://www.codewars.com/kata/5ab84aa4206a29ce21000047/train/javascript
</p>
JavaScript
const areaOrPerimeter=(l, w)=>(l==w)?l*w:2*(l+w)
// comments count as code
// this one-liner is 65 characters long
// take out spaces,paren,deep equal, only get to 45
const areaOrPer1meter=(l,w)=>l==w?l*w:2*(l+w)
// nope
const areaOrPer2meter=(l,w)=>2*(w||l+w)
//passes code length but nothing else =)
const areaOrPer3meter=(l,w)=>2*w&&l+w
// need solution this short. can not change name of func
const areaOrPer4meter=(l,w)=>l-w?2*(l+w):l*w
console.log(areaOrPer4meter(5,6))