Skip to content
Advertisement

Tag: tree

Derecursing this specific JS function

I wrote the following recursive JS function that takes a single parameter node which is made of other nodes and modifies it by adding to each node its number of leaves (not only direct children) : Here’s an example of the node parameter : addWidth(object) would modify it and turn it into : I need help to make my function

Build nodes like array from flat array

I’m trying to restructure the following javascript flat array without parent_id. I want to have a structure for React Tree Table like example in this page: https://www.robinwieruch.de/react-tree-table/ I want a another array that dynamically group according to this array’s keys: I want to have a structure like this and pass an another array to group. Ideally a want sum the

build array of object from tree object

I’m trying to get into javascript’s built-in reduce function and with the help of that build objects inside array. But you can use whatever function or method you want. Expected output What I tried to do I created a function which takes array as an argument and calls reduce for each array’s element. But it gives me output that I

How to find path from tree of nodes

Consider a data structure similar to the one below: The function I have tried is as follows using recursion. I am getting an output: [{name: ‘Link10’, url: ‘link10’}] I would like to get an output as follows: And if I call the function as follows: Should return results as [{name: ‘Link11’, url: ‘link11’,}] I tried the following as well and

Advertisement