How to merge duplicates in an array of objects and sum a specific property? : <p>I have this array of objects:</p>

<pre><code>var arr = [
    {
        name: 'John',
        contributions: 2
    },
    {
        name: 'Mary',
        contributions: 4
    },
    {
        name: 'John',
        contributions: 1
    },
    {
        name: 'Mary',
        contributions: 1
    }
];
</code></pre>

<p>... and I want to merge duplicates but sum their contributions. The result would be like the following:</p>

<pre><code>var arr = [
    {
        name: 'John',
        contributions: 3
    },
    {
        name: 'Mary',
        contributions: 5
    }
];
</code></pre>

<p>How could I achieve that with JavaScript?</p>
