Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. let arr1 = [
  2. {id = 1,
  3. name = "Anna"},
  4.  
  5. {id = 2,
  6. name = "Chris"}
  7. ]
  8.  
  9. let arr2 = [
  10. {childName = "Brian",
  11. {source = 1}},
  12. {childName = "Connie",
  13. {source = 2}}
  14. {childName = "Dory",
  15. {source = 1}}
  16. ]
  17.  
  18. arr1.forEach(el => el.children = arr2.filter(checkMatch));
  19.  
  20. function checkMatch(child){
  21. for(let i=0;i<arr1.length;i++){
  22. child.childName.source === arr1[i].id
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement