Guest User

Untitled

a guest
Jan 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. var Tree = function (value) {
  2. this.value = value;
  3. this.children = [];
  4. }
  5.  
  6. Tree.prototype.map = function(callback) {
  7. var newTree = new Tree(callback(this.value));
  8. this.children.forEach(child => {
  9. newTree.children.push(child.map(callback));
  10. });
  11. return newTree;
  12. };
Add Comment
Please, Sign In to add comment