Untitled
user_8712311
javascript
01/02/2024 3:02 PM
648 B
40
Indexable
const finalList = products
.filter(el =>
(el.name.toLowerCase().includes(filterText.toLowerCase()) &&
(!inStockOnly || (inStockOnly && el.stocked)))
)
.reduce((a, c) => {
const categoryRow = c.category !== a.lastCategory ? [<ProductCategoryRow key={c.category} category={c.category} />] : [];
return { lastCategory: c.category, output: [...a.output, ...categoryRow, <ProductRow key={c.name} product={c} />] };
}, { lastCategory: null, output: [] });
Editor is loading...
Leave a Comment