JSFiddle - React, Tailwind, and code Playground
by luka kupunia
JavaScript
const enrichedCompetitions = competitions
.map((competition) => ({
...competition,
Matches: (competition.MatchIds || []).map((matchId) => matches ?.[matchId]).filter(Boolean),
}))
.filter(({
Matches
}) => Matches.length > 0);
// Assuming 'enrichedCompetitions' is the final result you're interested in