I have a list of books. it can filter by category. How can I show all books if select "all" category.
books.filter(book => book.category.includes(currentcategory)).map(book =>
<div>
.
.
</div>
I have a list of books. it can filter by category. How can I show all books if select "all" category.
books.filter(book => book.category.includes(currentcategory)).map(book =>
<div>
.
.
</div>
There's plenty of ways to do this, but here's one:
(currentcategory === "all"
? books
: books.filter(book => book.category.includes(currentcategory))
).map(book =>
<div>
.
.
</div>
)