I have two arrays.
Array 1: One array is an array of objects:
arr1 = [{id:1, age:10}, {id:2, age:12}]
Array 2: The second array is just an array of ids:
arr2 = [3,4,1,5,2]
My goal is to combine the two arrays, but first taking the objects from the first array, and then to it joining the elements from the second array only taking the ids that are not already there in arr1. The second array elements need to be converted into objects. The end result of the above example will be:
newArray = [{id:1, age:10}, {id:2, age:12}, {id:3}, {id:4}, {id:5}]
I'm really confused about how to do this given the mix of objects and integers as array items.