Use Switch for Pattern Matching
Instead of complicated if/else if/else
, use switch instead for better readability.1
const howSoon = (days) => { switch (true) { case days <= 7: return 'soon'; case days > 7 && days < 30: return 'kind-of-soon'; case days >= 30: return 'not-soon'; default: return; }};