title: Merge and combine item into array based on property
body: <p>I am trying to merge an object into an array. Based on the title of the object, if it already exists in the array I want to add the amount of the object into the existing amount.</p>
  
  <p>For example:</p>
  
  <pre><code>let items = [{"title":"x","amount":1}, {"title":"y","amount":1}, {"title":"z","amount":1}];
  let obj1 = {"title":"x","amount":2};
  </code></pre>
  
  <p>If obj1 is merged into items the expected output would be </p>
  
  <pre><code>[{"title":"x","amount":3}, {"title":"y","amount":1}, {"title":"z","amount":1}]
  </code></pre>
  
  <p>Here is the solution I've come up with so far, Its working but I feel like there has to be a more elegant solution out there.</p>
  
  <pre><code>mergeResponses(x){
      var found = this.items.some(function (arr) {
          return arr.title === x.title;
      });
      if(!found){
          //item doesnt exist, add to array
          this.items.push(x);
      }else{
          //item already exists, add amount to existing amount
          let dupItem = this.items.find(function (y) {
              return y.title == x.title;
          });
          dupItem.amount += x.amount;
      }
  }
  </code></pre>