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