I am trying to pull an object from an array of objects that's property value is contained in my other array.
const myArrayOfObjects = [
{ value: 'test1' }
{ value: 'test2' }
]
const myArray = [ 'test1', 'test5' ];
const pluckedValue = myArrayOfObjects.find((item) => {
let x;
myArray.forEach((include) => {
x = include === item.value ? include : undefined;
});
return item.value === x;
});
What I have works but it feels wrong. Is there a nicer way to accomplish this? Is this efficient? I have access to lodash and ES6 in my application.
myArrayOfObjects.find((item) => myArray.includes(item.value) });