I'm new to JS and React and I'm a little stuck here. I've searched through SO but I'm having trouble finding a solution with an explanation that works.
Here are my arrays.
The first array is pretty simple.
[1, 3, 4,]
The second looks like this.
[
{
id: 1,
title: Title 1,
},
{
id: 2,
title: Title 2,
},
]
What I'd like to do is search the second array and if I can find an id that matches a value in the first array, add the object from the second array to third, new array.
I've tried a number of things and I'm sure there's a relatively easy way to do this with a forEach loop or lodash but I'm coming up blank.
Any help and explanations would be greatly appreciated.
Thanks,
I've tried a number of thingsPlease post what you've tried.