Homework12+_Suttipong_Taoun
Anonymous
javascript
01/02/2024 2:39 PM
588 B
39
Indexable
const myFilter = products.filter( el => (el.name.toLowerCase().indexOf(filterText.toLowerCase()) !== -1) && (!inStockOnly || el.stocked))
const finalList = myFilter.reduce( (a,c) => {
c.category !== a.lastCategory && a.output.push( <ProductCategoryRow key={c.category} category={c.category} />), a.lastCategory = c.category
a.output.push(<ProductRow key={c.name} product={c} />)
return a
},{lastCategory:null, output: []})Editor is loading...
Leave a Comment