title: Merge multiple array of objects and sum duplicate values javascript
body: <p>I have multiple arrays, which looks like this</p>
  
  <p>1st array of object looks like this</p>
  
  <pre><code>Array[4]
  
      0 : Object
          price:"2"       
          ref:"A"
      1 : Object
          price:"20"
          ref:"B"
      2 : Object
          price:"23"      
          ref:"C"
      3 : Object
          price:"23"      
          ref:"D"     
  </code></pre>
  
  <p>2nd array of objects looks like this</p>
  
  <pre><code>Array[4]
  
      0 : Object
          price:"12"      
          ref:"A"
      1 : Object
          price:"5"       
          ref:"B"
      2 : Object
          price:"23"      
          ref:"E"
      3 : Object
          price:"23"      
          ref:"F" 
  </code></pre>
  
  <p>And my third object looks like this.</p>
  
  <pre><code>Array[2]
  
  0 : Object
      name:"Blah"     
      fcp:"erol"
  1 : Object
      name:"Blah2"        
      fcp:"tpep"
  </code></pre>
  
  <p>Now i want to sum the <code>price</code> based on <code>ref</code>. 1st object and 2nd object has ref A and B common. So that the final object looks like</p>
  
  <pre><code>Array[7]
  
      0 : Object
          price:"14"      
          ref:"A"
      1 : Object
          price:"25"
          ref:"B"
      2 : Object
          price:"23"      
          ref:"C"
      3 : Object
          price:"23"      
          ref:"D" 
      4 : Object
          price:"23"      
          ref:"E"
      5 : Object
          price:"23"      
          ref:"F" 
      6 : Object
          name:"Blah"     
          fcp:"erol"
      7 : Object
          name:"Blah2"        
          fcp:"tpep"  
  </code></pre>