Answer the question
In order to leave comments, you need to log in
How to traverse a tree recursively?
How to recursively get width value from all nesting levels?
jsbin.com/gecabacu/1/edit?js
Answer the question
In order to leave comments, you need to log in
const getWidths = data =>
[].concat(data || []).reduce((acc, n) => {
if (n.hasOwnProperty('width')) {
acc.push(n.width);
}
acc.push(...getWidths(n.columns));
return acc;
}, []);
for in + recursion. Or is it as difficult as using the "code" button to properly format the question?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question