title: Convert nested Array of Objects to one dimensional Array of Objects Javascript/React
body: <p>I have a nested array of objects which I need to convert to one dimensional Array of objects. In the final Array the 'childrens' is not required.</p>
  <p>&quot;Edit&quot;: I also need to concatenate the path values of childrens</p>
  <p>Original Array</p>
  <pre><code>const data = [
  {
      title: &quot;Dashboard&quot;,
      icon: &quot;Dashboard&quot;,
      page:&quot;&lt;Dashboard./&gt;&quot;,
      path: &quot;dashboard&quot;                
  },
  {
      title: &quot;Management&quot;,
      icon: &quot;Management&quot;,
      page:&quot;&lt;Management/&gt;&quot;,
      path: &quot;manage&quot;,
      childrens:[
          {
              title: &quot;Assets&quot;,
              icon: &quot;Dot&quot;,
              page:&quot;&lt;Assetshome/&gt;&quot;,
              path: &quot;assets&quot;,
              childrens:[
          
                  {
                      title: &quot;MyAssets&quot;,
                      icon: &quot;Dot&quot;,
                      page:&quot;&lt;Myassets/&gt;&quot;,
                      path: &quot;myassets&quot;
  
                  },
                  {
                      title: &quot;AddAssets&quot;,
                      icon: &quot;Dot&quot;,
                      page:&quot;&lt;Addassets/&gt;&quot;,
                      path: &quot;addassets&quot;
  
                  }                    
              ]
          },
          {
              title: &quot;Users&quot;,
              icon: &quot;Dot&quot;,
              page: &quot;&lt;Users/&gt;&quot;
              path: &quot;users&quot;
          },
          {
              title: &quot;Office&quot;,
              icon: &quot;Dot&quot;,
              page:&quot;&lt;Office/&gt;&quot;
              path: &quot;office&quot;
          }            
  
      ]
  },
  {
      title: &quot;Reports&quot;,
      icon: &quot;Reports&quot;,
      page:&quot;&lt;Reports/&gt;&quot;
      path: &quot;reports&quot;
  } 
  </code></pre>
  <p>]</p>
  <p>Required flattened Array having path values of childrens concatenated.</p>
  <pre><code>const newdata = [
  {
      title: &quot;Dashboard&quot;,
      icon: &quot;Dashboard&quot;,
      page:&quot;&lt;Dashboard/&gt;&quot;,
      path: &quot;dashboard&quot;
              
  },
  {
      title: &quot;Management&quot;,
      icon: &quot;Management&quot;,
      page:&quot;&lt;Management/&gt;&quot;,
      path: &quot;manage&quot;
  },
  {
      title: &quot;Assets&quot;,
      icon: &quot;Dot&quot;,
      page:&quot;&lt;Assetshome/&gt;&quot;,
      path: &quot;manage/assets&quot;
  },
          
  {
      title: &quot;MyAssets&quot;,
      icon: &quot;Dot&quot;,
      page:&quot;&lt;Myassets/&gt;&quot;,
      path: &quot;manage/assets/myassets&quot;
  
  },
  {
      title: &quot;AddAssets&quot;,
      icon: &quot;Dot&quot;,
      page:&quot;&lt;Addassets/&gt;&quot;,
      path: &quot;manage/assets/addassets&quot;
  
  },               
         
  {
      title: &quot;Users&quot;,
      icon: &quot;Dot&quot;,
      page: &quot;&lt;Users/&gt;&quot;
      path: &quot;users&quot;
  },
  {
      title: &quot;Office&quot;,
      icon: &quot;Dot&quot;,
      page:&quot;&lt;Office/&gt;&quot;
      path: &quot;office&quot;
  },   
  {
      title: &quot;Reports&quot;,
      icon: &quot;Reports&quot;,
      page: &quot;&lt;Reports/&gt;&quot;
      path: &quot;reports&quot;
  } 
  </code></pre>
  <p>]</p>
  <p>What is the best way to do this in javascript.</p>