Untitled

 avatar
unknown
javascript
2 years ago
404 B
5
Indexable
const finalList = products.reduce((a, c) => {
  if (c.name.toLowerCase().includes(filterText.toLowerCase()) && (inStockOnly ? c.stocked : true)) {
    if (a.last !== c.category) a.output.push(<ProductCategoryRow key={c.category} category={c.category} />);
    a.output.push(<ProductRow key={c.name} product={c} />);
    a.last = c.category;
  }
  return a;
}, { last: null, output: [] }).output;
Editor is loading...
Leave a Comment