title: Groupby without using underscore js
body: <p>I have a collection which is group by ID. Each id contains array of objects. I want to loop through it and create a target collection which will be group by "Id" column as shown on the example. I will not use underscore js. I have to use javascript reduce method to achieve this.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var targetCollection = [{
      123456: [
          { "Id": "1", "name": "xxx", "age": "22" },
          { "Id": "1", "name": "yyy", "age": "15" },
          { "Id": "5", "name": "zzz", "age": "59" }
      ],
      789456: [
          { "Id": "1", "name": "xxx", "age": "22" },
          { "Id": "1", "name": "yyy", "age": "15" },
          { "Id": "5", "name": "zzz", "age": "59" }
      ]
  }]
  
  var targetOutput = [{
      123456: {
          1: [{ "Id": "1", "name": "xxx", "age": "22" }, { "Id": "1", "name": "yyy", "age": "15" }],
          5: [{ "Id": "5", "name": "zzz", "age": "59" }]
      },
      789456: {
          1: [{ "Id": "1", "name": "xxx", "age": "22" }, { "Id": "1", "name": "yyy", "age": "15" }],
          5: [{ "Id": "5", "name": "zzz", "age": "59" }]
      }
  }]</code></pre>
  </div>
  </div>
  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>Code Snippet I have tried which didn't work
  
  var newArray = [];
  $.each(targetCollection, function (key, value) {
      var newTarget = $(this);
      var targetCollectionNew = newTarget.reduce(function (result, current) {
          result[current.ParentAreaID] = result[current.ParentAreaID] || [];
          result[current.ParentAreaID].push(current);
          return result;
      }, {});
  
      newArray.push(targetCollectionNew);
  });
  
  console.log('newArray', newArray);</code></pre>
  </div>
  </div>
  </p>
  
  <p>I have tried with array reduce method and it didn't work. Please help me. </p>