Suppose we have two variables, x
and y
. The task at hand is to compare these variables using JavaScript code in order to generate the output
by eliminating any duplicate data.
Duplicate data here refers to instances where both
x
andy
contain values: 202, 203, 204, 205.
var x = [{'pID': 200},{'pID': 201},{'pID': 202},{'pID': 203},{'pID': 204},{'pID': 205}];
var y = [{'fID': 202},{'fID': 203},{'fID': 204},{'fID': 205}];
output = [{'ID': 200}, {'ID': 201}];
How can this be achieved? The two variables share some common data points but with different key names. Please advise if there are any errors in my naming conventions.
The JSON array
x
functions as the primary data source, meaning it contains more data than the JSON arrayy
.
Thank you.