compare array of objects
问题 Compare Array of Objects function compare (arr1, arr2){ //if object key value pair from arr2 exists in arr1 return modified array for (let obj of arr2) { if(obj.key === arr1.key){ return obj } } } // Should return [{key: 1, name : "Bob", {key: 2, name : "Bill"}] compare([{key: 1}, {key: 2}], [{key: 1, name : "Bob"}, {key: 3, name : "Joe"}, {key: 2, name : "Bill"}]) I am having a disconnect with looping arrays of objects with different lengths and properties. I have tried looping and IndexOf