Combining Objects

You just got hired on as a developer at a company that has customer-facing software. Your project lead comes to you and says they've been dealing with an issue where their users have been able to sign up for multiple accounts using the same name and email address. (They forgot to write validation that stops a user from signing up again if the email they use is already in the database!)

Your job is to write a function that can take an array of uniform user objects (every object in the array has the exact same properties: name, email, and numFriends) and returns a new array where the objects are combined. You should only combine objects if the name and email properties have the same values as another object in the array.

Example:

Given the following array:

var people = [
    {
        name: "Jim",
        email: "jim@gmail.com",
        numFriends: 10
    },
    {
        name: "Jim",
        email: "jim@gmail.com",
        numFriends: 30
    },
    {
        name: "Jane",
        email: "jane@gmail.com",
        numFriends: 200
    }
]

Your function should return an array like this:

var people = [
    {
        name: "Jim",
        email: "jim@gmail.com",
        numFriends: 40  // combined with the other user named `jim` with the email of `jim@gmail.com`
    },
    {
        name: "Jane",
        email: "jane@gmail.com",
        numFriends: 200
    }
]