Untitled
unknown
javascript
2 years ago
484 B
27
Indexable
const finalList = products.reduce((a, c) => { const isCategoryChanged = c.category !== a.lastCategory; a.output.push( (isCategoryChanged ? <ProductCategoryRow key={c.category} category={c.category} /> : <ProductRow key={c.name} product={c} /> ) * (c.name.toLowerCase().includes(filterText.toLowerCase()) && (!inStockOnly || c.stocked)) ); a.lastCategory = c.category; return a; }, { lastCategory: null, output: [] });
Editor is loading...
Leave a Comment