I'm learning by coding, here i have 'allNodes' an array of objects and 'currentNodee' object, i want to check if allNodes contains 'analyser' and 'id' which is equal to 'analyser' and 'id' of 'currentNodee' then take 'analyser' value and print it, but if for example 'allNodes' has same id but its analyser is 'undefined' then do not print anything.
what am i doing wrong here ? any idea is appreciated
const allNodes = [
{ analyser: undefined, id: 7 },
{ analyser: "abc", id: 6 },
];
const currentNodee = { analyser: "abc", id: 7 };
console.log(
allNodes.find((option: any) => {
option.id === currentNodee.id &&
option?.analyser === currentNodee?.analyser;
})
);
English is not my mother language so could be mistakes.
{} === {} // false