Untitled
unknown
javascript
a year ago
533 B
8
Indexable
const finalList = products .filter(el => el.name.toLowerCase().includes(filterText.toLowerCase()) && (!inStockOnly || (inStockOnly && el.stocked)) ) .reduce((acc, product) => { if (product.category !== acc.lastCategory) { acc.output.push(<ProductCategoryRow key={product.category} category={product.category} />); acc.lastCategory = product.category; } acc.output.push(<ProductRow key={product.name} product={product} />); return acc; }, { lastCategory: null, output: [] });
Editor is loading...
Leave a Comment