My current code has a method that is not very efficient and does not scale well.
The object y is an array consisting of key/value pairs, each containing two properties:
1. A unique string property called name. This value is identified by the children property, which is another array of objects similar to y.
for (var i = 0; i < y.length; i++) {
let objx = y[i];
let name = objx["name"];
let inner = objx["children"];
for (var j = 0; j < inner.length; j++) {
var z = inner[j]["name"];
let h = inner[j]["children"];
console.log(h);
}
// More nested loops on the 'h' object will follow.
}
I am wondering if there could be a more streamlined method that can generate a new collection containing all the name string properties until each respective children property returns a count of zero.