title: Add values in Array based on other multiple values then regroup
body: <p>I have this data:</p>
  
  <pre><code>var data = [
    [1, "San Miguel National Central High School", "School", 1],
    [1, "San Miguel Central Elementary School", "School", 2],
    [2, "Medrano's Rice Mill and Warehouse", "Warehouse", 3],
    [1, "Unknown", "Residential", 341],
    [2, "Unknown", "Residential", 532],
    [3, "Unknown", "Residential", 257],
    [2, "Unknown", "Gas Station", 1]
  ];
  </code></pre>
  
  <p>And the intended ouput should be like this:</p>
  
  <pre><code>var data = [
    ["School", 3,0,0],
    ["Warehouse", 0,3,0],
    ["Residential", 341, 532, 257],
    ["Gas Station", 0,1,0]
  ];
  </code></pre>
  
  <p>For its representation,</p>
  
  <ul>
  <li>data[i][0] --> Level </li>
  <li>data[i][1] --> Building Name</li>
  <li>data[i][2] --> Building Type</li>
  <li>data[i][3] --> Count</li>
  </ul>
  
  <p>The result should have this sequence:</p>
  
  <blockquote>
    <p>Building Type, Level 1 Count, Level 2 Count, Level 3 Count</p>
  </blockquote>
  
  <p>If the array has the same level and same building type the count value should be added.</p>
  
  <p>How to achieve this using JavaScript or JQuery?</p>