Loading...
Loading...
const tree = {
type: "nested",
children: [
{ type: "added", value: 42 },
{
type: "nested",
children: [{ type: "added", value: 43 }],
},
{ type: "added", value: 44 },
],
};
You need to write a function getNodes(tree, type) that returns all nodes in order that match the given type. The nesting depth can be any.Run your code to see results.
Click the Run button above
const tree = {
type: "nested",
children: [
{ type: "added", value: 42 },
{
type: "nested",
children: [{ type: "added", value: 43 }],
},
{ type: "added", value: 44 },
],
};
You need to write a function getNodes(tree, type) that returns all nodes in order that match the given type. The nesting depth can be any.