JSFiddle - React, Tailwind, and code Playground

by MuLtDirectX

JavaScript

var tree = [
	{
  	name: 'ololo',
  	children: [
  		{
    		name: 'ololo2',
    		children: [{name: 'ololo3'}]
    	}
   	]
   },
   
  {
  	name: 'something',
  	children: [
  		{	name: 'something2',
      	children: [
      		{name: 'something3',
        children: [{name: 'something4'}]
        	}
      	]
    	}
  	]
  },
  
  {
  	name: 'I do not have children'
  },
  
  {
  name: 'lastone',
  children: [{name: 'lastchild'}]
  }
]




function getNames(array){
	let newArr = []
  	 	function printName() {
      	for (let i=0; i < array.length; i++){
        	
        }
        return newArr
      }
}

console.log(getNames(tree))