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