Untitled

mail@pastecode.io avatar
unknown
javascript
2 months ago
451 B
1
Indexable
Never
const finalList = products.reduce( (a, c) => {
        if((!c.name.toLowerCase().includes(filterText.toLowerCase().trim())) || (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: [] } )
Leave a Comment