I can get the values of same values inside a nested map. But how to get the difference between the two?
I tried map, filter but I can't get the hang of how to do it properly for removing the duplicate values.
const responseData = [
{ value: "red", label: "Red" },
{ value: "blue", label: "Blue" }
];
const fixedColors = [
{ value: "red", label: "Red" },
{ value: "blue", label: "Blue" },
{ value: "yellow", label: "Yellow" },
{ value: "orange", label: "Orange" }
];
responseData.map(opt => {
fixedColors.findIndex(obj => {
if (obj.value === opt.value) {
testArray.push(opt);
} else {
testArray2.push(obj);
}
});
});
I can get the same values on both arrays, I can't get the difference. I don't get how to properly execute it using ES6.