Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let arr1 = [
- {id = 1,
- name = "Anna"},
- {id = 2,
- name = "Chris"}
- ]
- let arr2 = [
- {childName = "Brian",
- {source = 1}},
- {childName = "Connie",
- {source = 2}}
- {childName = "Dory",
- {source = 1}}
- ]
- arr1.forEach(el => el.children = arr2.filter(checkMatch));
- function checkMatch(child){
- for(let i=0;i<arr1.length;i++){
- child.childName.source === arr1[i].id
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement