I am faced with a scenario where I have 4 separate arrays and need to identify if any item appears in more than two of the arrays. If this is the case, I must delete the duplicate items from all arrays except one based on a specific property.
let arrayA = [{id: 1, modifiedOn: 1234}, {id: 2, modifiedOn: 1234}, {id: 3, modifiedOn: 1234}]
let arrayB = [{id: 4, modifiedOn: 1234}, **{id: 2, modifiedOn: 1235}**, {id: 5, modifiedOn: 1234}]
let arrayC = [{id: 6, modifiedOn: 1234}, {id: 7, modifiedOn: 1234},
**{id: 5, modifiedOn: 1235}**
let arrayD = [**{id: 1, modifiedOn: 1235}**, {id: 8, modifiedOn: 1234}, {id: 9, modifiedOn: 1234}]
Upon examining the arrays above, it is clear that ids 2, 5, and 1 are present in more than one array. The rule is to keep the item with the highest value for the modifiedOn property and remove the others.