I have two result sets like this:
// Result 1
[
{ value: \"0\", display: \"Jamsheer\" },
{ value: \"1\", display: \"Muhammed\" },
{ value: \"2\",
Most of answers here are rather complex, but isn't logic behind this quite simple?
const getArraysDifference = (longerArray, array2) => {
const difference = [];
longerArray.forEach(el1 => { /*1*/
el1IsPresentInArr2 = array2.some(el2 => el2.value === el1.value); /*2*/
if (!el1IsPresentInArr2) { /*3*/
difference.push(el1); /*4*/
}
});
return difference;
}
O(n^2) complexity.