I am building an app using ReactJS library and trying to figure out how to return a difference after comparing two arrays.
const a = [8,10,13,14];
const b = [{id: 8}, {id: 13}, {id: 14}];
and what I would like to get is
[10]
.
What I have tried and didn't work was using map and filter together.
const newArray = b.map((itemB) => {
return a.filter(
itemA => itemB.id !== itemA,
);
});
What is the simple way of returning this?
Thanks.