title: Re indexing array-object in jquery
body: <p>I have an array with object like this</p>
  
  <pre><code>var arr = [
    {'key1':'A','key2':1,'key3':0.04,'key4':10},
    {'key1':'B','key2':1,'key3':0.03,'key4':20},
    {'key1':'B','key2':2,'key3':0.05,'key4':30},
    {'key1':'A','key2':1,'key3':0.03,'key4':40},
    ...
  ];
  </code></pre>
  
  <p>Inside array there can be unlimited objects. I need to create new array where every key1 and key2 must save unique and if same key1 and key2,then key3 must be added. My result for above array look like this</p>
  
  <pre><code>//Can be array or object
  var a = [
    ['A'][1] =&gt; {'key3':0.07,'key4':50},
    ['B'][1] =&gt; {'key3':0.07,'key4':20},
    ['B'][2] =&gt; {'key3':0.05,'key4':30}
  ];
  </code></pre>
  
  <p>My result can be array or object. What I have tried is</p>
  
  <pre><code>var a = {};
  arr.forEach(function(obj){
    if(a[obj.key1]){
      if(a[obj.key1][obj.key2]){
        a[obj.key1][obj.key2] += obj.key3;
      }else{
        a[obj.key1][obj.key2] = obj.key3;
      }
    }else{
      a[obj.key1] = obj.key1;
    }
  });
  console.log(a);
  </code></pre>
  
  <p>And I am getting only depth of result. Please suggest me how can I get my result output from given array object.
  Thanks in advance.</p>