...

/

Solution Review: Avoiding Duplicates

Solution Review: Avoiding Duplicates

Learn to avoid showing duplicated search.

We'll cover the following...

Solution:

The source of the five rendered buttons is the getLastSearches function. There, we take the array of urls and return the last five entries from it. Now we’ll change this utility function to return the last six entries instead of five, removing the last one. Afterward, only the five previous searches are displayed as buttons.

Press + to interact
const getLastSearches = urls =>
urls
.slice(-6)
.slice(0, -1)
.map(extractSearchTerm);

If the same ...

Access this course and 1400+ top-rated courses and projects.