I have an object that contains people's names and ages
{"John":44,"Sarah":23,"Bob":43,"Kate":65,"Bill":18}
and an array that provides a list of employee names
['John', 'Bob', 'Kate', 'Bill', 'Fred']
I would like to create a new object which contains only those people and their ages that appear in both the object and array. So in this example the new object would contain
{"John":44,"Bob":43,"Kate":65,"Bill":18}
"Sarah":23
and Fred
don't appear because they appear in only one of the above.
Can anyone advise on how to do this please?