Untitled
user_4355577
plain_text
a year ago
598 B
5
Indexable
const filteredProducts = products .filter(el => el.name.toLowerCase().includes(filterText.toLowerCase()) && (!inStockOnly || (inStockOnly && el.stocked)) ); const groupedProducts = filteredProducts.reduce((acc, current) => { const { category } = current; const isNewCategory = category !== acc.lastCategory; acc.output.push( isNewCategory ? <ProductCategoryRow key={category} category={category} /> : <ProductRow key={current.name} product={current} /> ); acc.lastCategory = category; return acc; }, { lastCategory: null, output: [] });
Editor is loading...
Leave a Comment