title: Convert JSON format (Group by)
body: <p>I have JSON object like this:</p>
  
  <pre><code>[{
      "name" : "cat",
      "value" : 17,
      "group" : "animal",
  },
   {
      "name" : "dog",
      "value" : 6,
      "group" : "animal",
  },
   {
      "name" : "snak",
      "value" : 2,
      "group" : "animal",
  },
  {
      "name" : "tesla",
      "value" : 11,
      "group" : "car",
  },
  {
      "name" : "bmw",
      "value" : 23,
      "group" : "car",
  }]
  </code></pre>
  
  <p>I want to convert this JSON to below format by JS:</p>
  
  <pre><code>[{
    "name":"animal",
    "children":[
       {"name":"cat", "value":17},
       {"name":"dog", "value":6},
       {"name":"snak", "value":2}
  ]},
  {
    "name":"car",
    "children":[
       {"name":"bmw", "value":11},
       {"name":"tesla", "value":23}
  ]}]
  </code></pre>
  
  <p>I try to convert and filter by <code>Reduce</code> function but I couldn't convert to this format.</p>
  
  <p>EDIT:</p>
  
  <p>The code I tested was this.</p>
  
  <pre><code>let groupBy = function(xs, key) {
      return xs.reduce(function(rv, x) {
      (rv[x[key]] = rv[x[key]] || []).push(x);
      return rv;
      }, {});
  };
  
  let groubedByExchange=groupBy(JSON_data, 'group');
  </code></pre>