Before taking this challenge, we recommend that you go through and analyze the teacher's solution in the "Building an itinerary" challenge.
Implement and export as default a function that builds a tree relative to a given root node.
The function takes 2 arguments:
- source tree
- the root node for a new tree to built
The function should return a new tree preserving links between nodes, where the passed node is the root.
const tree = ['A', [ // A ['B', [ // / \ ['D'], // B C ]], // / / \ ['C', [ // D E F ['E'], ['F'], ]], ]]; transform(tree, 'B'); // ['B', [ // B // ['D'], // / \ // ['A', [ // D A // ['C', [ // \ // ['E'], // C // ['F'], // / \ // ]], // E F // ]], // ]];
- Other examples can be found in the tests file
- Use the lodash lib functions
For full access to the challenge you need a professional subscription.
A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.
hours of theory