I'm trying to get a new array of tracks that have the same genre music id that genreFilter.
So if genreFilter is 12 I need the new array have tracks with genre music id = 12. But the list of genres is other array so I think I need iterate it too and then return the track.
I'm doing the next
const list = tracks
.map((track) =>
track.primary_genres.music_genre_list.filter((genre) => {
if (
genre.music_genre &&
genre.music_genre.music_genre_id === genreFilter
) {
return track;
}
})
);
But this only return genres which is obtained by filter function and doesn't return the track.