title: Combining two Object with multiple keys using angular 2
body: <p>I have two object, second should be merge or combined with the first array that results a new array.</p>
  
  <pre><code>this.firstArray = [{
     "field": "A",
     "value": ["1","2"]
     },{
     "field": "B",
     "value": ["1","2","3"]
     }]    
  
  this.secondArray = [{
      "type": "A",
      "option": 1,
      "count": 2
    },
    {
      "type": "A",
      "option": 2,
      "count": 1
    },
    {
      "type": "B",
      "option": 1,
      "count": 1
    },
    {
      "type": "B",
      "option": 3,
      "count": 1
    }]
  </code></pre>
  
  <p><strong>Desired Output:</strong> 
  Conditions: </p>
  
  <ul>
  <li><p>Field and Type should be the same</p></li>
  <li><p>Value and Options should also be the same</p></li>
  <li>return the count</li>
  <li><p>return <strong>0</strong> if none found in second Array</p>
  
  <pre><code>[{
     "field": "A",
     "value": ["1": 2,"2": 1]
     },{
     "field": "B",
     "value": ["1": 1,"2": 0,"3": 1]
     }]
  </code></pre></li>
  </ul>
  
  <p>What I did was just appending the json to its field that has the same field and type.. </p>
  
  <pre><code>this._finalArr = this.firstArray.map(val =&gt; {
            return Object.assign({}, val, this.secondArray.filter(v =&gt; v.field === val.type)[0]);
              });
              console.log(this._finalArr);
  </code></pre>