title: d3js v7 convert array into hierarchy
body: <p>I have data formatted as below</p>
  <pre><code>[['x',2,3,'a'],['x',2,4,'b'],['y',1,3,'a']]
  </code></pre>
  <p>I want to convert it into something like below</p>
  <pre><code>{
    'name': 'top level',
    'children':
      [
        {
          'name': 'x',
          'children':
            [
              {
                'name': 2,
                'children':
                  [
                    {
                      'name': 3,
                      'children':
                        [
                          {
                            'name': 'a',
                            'children': []
                          }
                        ]
                    },
                    {
                      'name': 4,
                      'children':
                        [
                          {
                            'name': 'b',
                            'children': []
                          }
                        ]
                    }
                  ]
              }
            ]
        },
        {
          'name': 'y',
          'children':
            [
              {
                'name': 1,
                'children':
                  [
                    {
                      'name': 3,
                      'children':
                        [
                          {
                            'name': 'a',
                            'children': []
                          }
                        ]
                    }
                  ]
              }
            ]
        }
      ]
  }
  </code></pre>
  <p>I want to graph the data into a clickable tidy tree.</p>
  <p>I couldn't use <code>d3.nest</code> since it was already deprecated and I have no idea how to do it with vanilla javascript. Any help is appreciated.</p>
  <p>Edit:
  based on pointers from @Andrei Savin I tried to run the following code. the problem is my array doesn't change, why?</p>
  <pre><code>let sampleInput = [['x',2,3,'a'],['x',2,4,'b'],['y',1,3,'a']];
  let result = [];
  let level = { result };
  
  sampleInput.forEach(b =&gt; {
    b.forEach(c =&gt; {
      c.toString().split('/').reduce((d,e)=&gt;{
        if(!d[e]){
          d[e] = {result:[]};
          d.result.push({e,'children':d[e].result});
        }
  
        return d[e];
      },level);
    })
  });
  </code></pre>