domainScores = domainsZScore.map(domain => ({
...domain,
domainScore: domain.indicators.reduce((memo, indicator) => indicator.values.map(value => {
const { geoid, zScore } = value;
const match = memo.find(m => m.geoid === geoid);
return {
geoid,
domainScore: match ? match.domainScore + zScore : zScore,
}
}), []).map(ds => ({
...ds,
domainScore: ds.domainScore / domain.indicators.length,
}))
}))