title: Sum of an array with a condition
body: <p>I want to sum the element value of the array, which have the same year.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var newData = [];
  var data = new Array(['2013', 0], ['2013', 0],['2016', 15], ['2017', 2], ['2015', 1], ['2013', 0], ['2016', 12], ['2014', 0], ['2017', 3], ['2015', 1], ['2013', 21], ['2013', 2]);
  
  var sum = data.reduce(function (a, b,i) {
      if (b[0][i]==b[0][i+1]) {
           return newData.push(b[0],a + b[1]);
         
      }    
   }, 0);
   console.log(newData);
   
   //return to:
   
  [
  ["2013",23],
  ["2014",0],
  ["2015",2],
  ["2016",27],
  ["2017",5]
  ]</code></pre>
  </div>
  </div>
  </p>
  
  <p>is it possible?
  Thank you for your help</p>