'Group objects if property values are the same

I'm trying to group the objects for the users that have the same location and type value shown in the example below. What would be the best way to approach this?

const diabetics = [
    {
        type: 'type 1',
        location: 'Boston'
        email: '[email protected]'
    },
    {
        type: 'type 2',
        location: 'New York'
        email: '[email protected]'
    },
    {
        type: 'type 1',
        location: 'Boston'
        email: '[email protected]'
    },
    {
        type: 'type 1',
        location: 'Maine'
        email: '[email protected]'
    },
]

// expected output 
const diabetics = [
    {
        type: 'type 1',
        location: 'Boston'
        email: [
        '[email protected]',
        '[email protected]'
        ]
    },
    {
        type: 'type 2',
        location: 'New York'
        email: '[email protected]'
    },
    {
        type: 'type 1',
        location: 'Maine'
        email: '[email protected]'
    },
]


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source