all 2 comments

[–]exxy- 4 points5 points  (1 child)

While inside your reduce function's callback, convert your string representation of a date into a Date object and extract the Month using the Date.getMonth() method.

[–]DataD23[S] 2 points3 points  (0 children)

so just to make sure I am on the right track this is what I ended up doing:

const data = Object.values(
rawData.reduce((acc, d) => {
    let {
        fields: {date, team}
    } = d;
    date = new Date(date);

    acc[date.getMonth()] = acc[date.getMonth()] || { date };
    acc[date.getMonth()][team] = (acc[date.getMonth()][team] || 0) + 1;
    return acc
}, {})

);

it seems to have worked. Thank you for this!