MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 23 HOURS 58 MINUTES 14 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 23 HOURS 58 MINUTES 12 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
// Recursive function
_.each(names, function(parent) {
if(parent.children.length > 0) {
recursiveFunction(parent.children);
}
});
function recursiveFunction(children){
_.each(children, function(child) {
if(child.children.length > 0) {
recursiveFunction(child.children)
}
});
};
// Deeply nested javascript object
var names = {
name: name-1 ,
value: 10,
valueTotal: 0, // should be 60 (name-1.1 + name-1.2 + name-1.2.1 + name-1.2.2 + name-1.2.2.1 + name-1.2.2.2)
children: [{
name: name-1.1 ,
value: 10,
valueTotal: 0,
children: []
}, {
name: name-1.2 ,
value: 10,
valueTotal: 0, // should be 40 (name-1.2.1 + name-1.2.2 + name-1.2.2.1 + name-1.2.2.2)
children: [{
name: name-1.2.1 ,
value: 10,
valueTotal: 0,
children: []
}, {
name: name-1.2.2 ,
value: 10,
valueTotal: 0, // should be 20 (name-1.2.2.1 + name-1.2.2.2)
children: [{
name: name-1.2.2.1 ,
value: 10,
valueTotal: 0,
children: []
}, {
name: name-1.2.2.2 ,
value: 10,
valueTotal: 0,
children: []
}]
}]
}]
}
}