I am trying to add a property (score) to my units array. Scores is an array of object that contains a common id with units.
this.units.map(unit => {
unit.score = scores
.filter(score => unit.id === score.unit_id);
});
The objects that are contained in the array.
scores
{
unit_id: 1234,
score: 12,
}
this.units
[
{
id: 1234,
type: 'maths',
}
{
id: '5678',
type: 'maths',
}
]
It looks ok. Is it because unit.id is not available in the filter?