I have my object that is stored in variable val.Main.widgets
. I also have variable that functions as a data tree. What I need is to generate as many children elements as there are keys in my object that is stored in val.Main.widgets
. If I console log this: console.log(Object.keys(val.Main.widgets).length;
, it returns 8 so in this case I need to generate 8 children elements.
I am guessing I need some sort of cycle, but I really dont know where to start, hence why I am asking here.
Here is my object:
And here is my tree variable:
const tileTree = [
{
name: val.Main.name,
children: [
{
name: val.Main.widgets['E1EV7'].name,
},
{
name: val.Main.widgets['E70ZT'].name,
},
],
},
];
Thank you for any advice.