I have a situation where I need to compare and find common values over two arrays. I am clear on how to do it with one, but not sure how to do it in this case.
My first array looks like this:
[ { kind: 'E',
path: [ 'short_name' ],
lhs: 'testing',
rhs: 'testing1' },
{ kind: 'E',
path: [ 'agent_name' ],
lhs: 'testing',
rhs: 'testing2' } ]
The array above represents information pertaining to what changed on a document.
My second array looks like this:
[ { lhs: 'legacyId', rhs: 'id_number' },
{ lhs: 'name.short', rhs: 'short_name' },
{ lhs: 'name.long', rhs: 'agent_name' },
{ lhs: 'gender', rhs: 'gender' },
{ lhs: 'dob', rhs: 'date_of_birth' } ]
What I need to do is loop through and find common values for "path" in the first array's elements, and the second array's "rhs" value.
So according to my examples here, I should end up with these values being found: short_name and agent_name.
How could I write a loop to do this over the two arrays?