-
-
Save xdesro/ab4d8de1833e4e68a303fc6fc3f172d7 to your computer and use it in GitHub Desktop.
Using a JS Set and Array.flat() to get only the unique values from many arrays.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const clients = [ | |
{ | |
name: 'Client A', | |
services: ['Web development', 'SEO', 'Web design', 'Full service agency'], | |
}, | |
{ | |
name: 'Client B', | |
services: [ | |
'Analytics', 'Email marketing', 'Marketing', 'SEO', 'Web design', 'Web development', 'Integration solutions', 'Full service agency','Advertising', | |
], | |
}, | |
]; | |
const uniqueServices = [ | |
...new Set(clients.map(({services}) => services).flat()), | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment