I'm dealing with two objects formatted like this.
{
"MediaListCollection": {
"lists": [
{
"entries": [
{
"mediaId": 121,
"score": 0
},
{
"mediaId": 5114,
"score": 10
}
}
I want to make a new object with all of the entries that appear in both objects (using mediaID as a key). I tried this code but apparently it doesn't work in React because filter is only used on arrays, not objects:
const sameShows = user1Shows.filter(user1Shows.filter(shows1 => user2Shows.some(shows2 => user1Shows.mediaID === user2Shows.mediaID)))
Using Object.entries(user1shows) doesn't fix the problem. I get a [object Array] is not a function error.