Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Tree = function (value) {
- this.value = value;
- this.children = [];
- }
- Tree.prototype.map = function(callback) {
- var newTree = new Tree(callback(this.value));
- this.children.forEach(child => {
- newTree.children.push(child.map(callback));
- });
- return newTree;
- };
Add Comment
Please, Sign In to add comment