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); }
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); }