I am trying to get the items that are in "colors" but not in "colors2" and show them, but instead i'm always getting all the items of the first array
let colors = [
{ key: "green", value: '#00b894' },
{ key: "lgreen", value: '#64ed9f' },
{ key: "yellow", value: '#edc611' },
{ key: "orange", value: '#fda044' },
{ key: "red", value: '#e74c47' }
]
let colors2 = [
{ key: "Option 1", value: "#00b894" },
{ key: "Option 2", value: "#e74c74" }
]
comparer = (otherArray) =>{
return function (current) {
return otherArray.filter(function (other) {
return other.value !== current.value
})
}
}
As for the output I am getting all the items of colors array. Instead I want to display lgreen, yellow and orange whose values are not the same as items in colors2 array.
Output :
Array [Object { key: "green", value: "#00b894" }, Object { key: "lgreen", value: "#64ed9f" }, Object { key: "yellow", value: "#edc611" }, Object { key: "orange", value: "#fda044" }, Object { key: "red", value: "#e74c47" }]