title: summarize values of objects with same attribute name
body: <p>I have an array filled with objects. The following example shows the structure of the objects.</p>
  
  <pre><code>let array = [
    { 
      data: [{name:'a', value:20}, {name:'b', value:10}, {name:'c', value:5}]
    },
    { 
      data: [{name:'d', value:20}, {name:'a', value:10}, {name:'e', value:40}]
    },
    { 
      data: [{name:'b', value:30}, {name:'a', value:5}]
    }
  ];
  </code></pre>
  
  <p>I'm trying to iterate through all the data values and summarize all the identical letters and sum up there values in a new array. So the new array should look like this:</p>
  
  <pre><code>let array = [{name:'a', value:35}, {name:'b', value:40}, {name:'c', value:5}, {name:'d', value:20}, {name:'e', value:40}];
  </code></pre>
  
  <p>This is my current approach but I don't get it to work.</p>
  
  <pre><code>let prevData = '';
  let summarizedArray = [];
  for(let i = 0; i &lt; array.length; i++) {
    for(let j = 0; j &lt; array[i].data.length; j++) {
  
      if(prevData === array[i].data[j].name) {
        let summarized = {
          name: array[i].data[j].name;
          value: prevData.value + array[i].data[j].value;
        }
        summarizedArray.push(summarized);
      }
  
      prevData = array[i].data[j]; 
    }
  }
  </code></pre>
  
  <p>// Edited Example:</p>
  
  <pre><code>let array = [
    { 
      data: [{name:'a', value1:20, value2:90, value3:'foo'},
             {name:'b', value1:30, value2:20, value3:'boo'}]
      },
      data: [{name:'c', value1:5, value2:10, value3:'goo'},
             {name:'a', value1:30, value2:20, value3:'foo'}]
      },
    { 
  ];
  </code></pre>
  
  <p>The values should be bundled by same names. The values of Value1 and Value2 should be added up and Value3 is always the same for each name.</p>
  
  <p>So the result should look like this:</p>
  
  <pre><code>let result = [{name:'a', value1:50, value2:110, value3:'foo'},
                {name:'b', value1:30, value2:20, value3:'boo'},
                {name:'c', value1:5, value2:10, value3:'goo'}
              ];
  </code></pre>