I have an array of objects with nested arrays inside that I want to compare and map through to only display the value that is not equal to one another.
Here is what I tried
const arrayObjOne = [
{ display: ["Stockholm", "Copenhagen", "Berlin"] },
{ display: ["Stockholm", "Copenhagen", "Berlin", "Oslo"] },
];
function Testpage() {
const results = arrayObjOne.filter(
({ display: data1 }) =>
!arrayObjOne.some(({ display: data2 }) => data1 === data2)
);
console.log(results);
return (
<div>
{results.map((data, i) => (
<ul>
<li>{data}</li>
</ul>
))}
</div>
);
}
export default Testpage;
The final result I need is to display the difference between these nested arrays – the final result should look something like this like this:
as a list, in this case
{['Oslo']}