Using param for symbol

PHOTO EMBED

Wed Jun 26 2024 02:40:48 GMT+0000 (Coordinated Universal Time)

Saved by @davidmchale #function #symbol #param

function getTotal(list, dir) {
  
  // where if dir is equal to either '>' or.'<'
  return list
    .filter(item => (dir === '<' ? item < 0 : item > 0) && item)
    .reduce((total, item) => (total += item), 0);
}
content_copyCOPY