0

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.

enter image description here

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!

1
  • 1
    Post the original array. Commented Aug 24, 2022 at 16:36

1 Answer 1

2

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))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.