title: Summarizing JavaScript array based on category and subcategory
body: <p>I've been trying to get the summary of the elements in my array. The array contains different values for different categories and i want to summarize the content of the array before the user checks the content of the array.
  here is the data:</p>
  
  <pre><code>var typed = [
  [1, 'MAP: Invalid service'],
  [2, 'MAP: map observation'],
  [3, 'ADT: Invalid person'],
  [4, 'ADT:  verification failed'],
  [5, 'SYSTEM: Unrecognized'],
  [6, 'SYSTEM: Processing exempt']
  [7, 'SYSTEM: Data access'],
  [8, 'SYSTEM: Data access'],
  [9, 'SYSTEM: Transform Exempt'],
  [10, 'SYSTEM: Transform Exempt'],
  [11, 'ADT:  verification failed'],
  [12, 'ADT: Invalid person']
  ]
  </code></pre>
  
  <p>I want something of this nature as the summary</p>
  
  <pre><code>  4 ADT :
            2 Invalid person
            2 verification failed
  
   2 MAP: 
            1 Invalid service
            1 map observation
  
   6 SYSTEM: 
            1 Unrecognized
            1 Processing exempt
            2 Transform exempt
            2 Data access
  
  ---------------------
  Total: 12
  </code></pre>
  
  <p>Here is what I tried:</p>
  
  <pre><code>function summary(typed, category){
      var arrA = [];
      var arrB = [];
      for (var i=0; i&lt;typed.length; i++){
          var tryb = typed[i][4].split(' ');
          for (var j=0; j&lt; category.length; j++){
              if (tryb[0] == category[j]){
              arrA[i][j] = typed[i];
              }
          }
      }
      return arrA;
  }
  var newcategory = ['ADT:','MAP:'];
  summary(typed, newcategory)
  </code></pre>