DEV Community

Discussion on: The case for reducers

Collapse
 
vonheikemen profile image
Heiker

Thanks for the kind words.


About those examples I made in the post, interestingly enough they could also be done using Array.flatMap.

  • Unique tags
new Set(posts.flatMap(({ tags }) => tags))
Enter fullscreen mode Exit fullscreen mode
  • FilterMap
posts.flatMap(({ tags, category }) =>
  tags.includes('discuss')
    ? capitalize(category)
    : []
);
Enter fullscreen mode Exit fullscreen mode