Вы можете использовать метод filter
для фильтрации массива.
const animals = [
"Cows", "Pigs", "Sheep", "Goats", "Lambs", "Rabbits"
];
let locations = [
{ Cows: 'Yes', },
{ Pigs: 'Yes', },
{ Sheep: 'Yes', },
{ Goats: 'Yes', },
{ Lambs: 'Yes', },
{ Rabbits: 'Yes', },
];
const _updateLocationData = (value) => {
var tempLocations = locations.filter(res => (animals.includes(value) && res[value] === 'Yes'));
console.log(tempLocations);
}
_updateLocationData('Cows');
_updateLocationData('Pigs');
_updateLocationData('Sheep');
_updateLocationData('Goats');