Good day, I have an array artists[]
of Proxy-objects. Proxy by themself also are arrays of objects (as I understood). Each of inner objects has property "artistName"
(photo). Meanwhile third Proxy has two.
I need to get smth like this:
[ ["Queen"], ["Pink Floyd"], ["Elvis Presley", "Pink Floyd"], ]
So, as result we get arrays of artist’s names grouped by Proxy objects. Please, help!
Advertisement
Answer
There are two levels of arrays, so you’ll need two loops (or map functions). Give this a try
const names = artists.map(grp => grp.map(band => band.artistName))