I'm trying to go trough JS object (1) to find out if value exists on another object (2) and return object (2) found value.
var returnObj = [];
selectedValues.forEach(function(value, key){
var found = valuesObject.some(function (el) {
if (el.item_id === value){
return el.item_id;
}
});
console.log(found);
});
in this case I can only find out if its exists or not by getting true/false and I've also tried this
var returnObj = [];
selectedValues.forEach(function(value, key){
console.log(_.intersection(valuesObject, value));
});
but in this case it returns me only empty arrays instead of object (2) value which was found by object (1) value