Here are two arrays:
var members = [{docId: "1234", userId: 222}, {docId: "1235", userId: 333}];
var memberInfo = [{id: 222, name: "test1"}, {id: 333, name: "test2"}];
I want to merge them into a single array by matching user ids programmatically.
The combined array should look like this:
var finalArray = [{docId: "1234", userId: 222, name: "test1"}, {docId: "1235", userId: 333, name: "test2"}]
I am looking for a more efficient way to do this. I have the underscore library in my application but couldn't find a clean method to achieve this.