I would like to know how to return true or false based on two array objects property using javascript
If arrobj1 and arrobj2 value
and country
same return true
I have tried below, may i know better way to do using javascript
Tried
for(var elem of arrobj1){
const result = arrobj2.filter(obj => obj.value === elem.value && obj.country === elem.country);
if(result.length > 0){
return true;
}
}
var arrobj1 =[
{id:1, name: "one", value:"sales", country:"MY"},
{id:2, name: "two", value:"finance", country:"PH"},
{id:3, name: "three", value:"digital", country:"SL"}
]
var arrobj2 =[
{id:4, name: "four", value:"digital", country:"SL"}
]
Expected Output
true