I have the following object:
const myObject = {
"-Lz8YxHiwp8QZW3TqAFn": Object {
"first": "Breanna",
"last": "Blah",
},
"-Lz8YxHqQXWoaGOFRLrO": Object {
"first": "Joshua",
"last": "Blah",
},
"-Lz8YxHsMItaaTVNyQRE": Object {
"first": "Joziah",
"last": "Blah",
},
"-Lz8YxHwuVBMWl0Go6C5": Object {
"first": "Lino",
"last": "Blah",
},
"-Lz8YxHy0S-QkDaE1PkX": Object {
"first": "Rebecca",
"last": "Blah",
},
"-Lz8YxI5IItUiXX6rFn_": Object {
"first": "Rosario",
"last": "Blah",
},
"-Lz8YxIB_YTBF8liL855": Object {
"first": "Alissa",
"last": "Blah",
}
}
then I have a set with the following:
const mySet = {
"-Lz8YxMp-V0TfiwrkM49",
"-Lz8YxNQP2WkkO0qpkRJ",
"-Lz8YxHy0S-QkDaE1PkX",
"-MmFNgjyopU3E8z5g-zU",
"-Lz8YxLVi_uZp_RkcRIH",
"-MuEgimJOIbPw3GyKBJ3",
"-Lz8YxOFpVHx2xPI1mUu",
"-Lz8YxJ-_wuk8bmEyvGT",
"-Lz8YxKj5WXY1oNwylQ4",
"-Lz8YxN87U1YM6_fKgq1",
"-Lz8YxOI4qszJvZhrSde",
"-Lz8YxI5IItUiXX6rFn_",
}
I need to return myObject with ONLY the objects that match an item in mySet.
I have done this with a map but it turns myObject into an array.
The following uses map and returns an array which I can’t use for this particular situation.
// const addGroupMembers = Object.entries(members)
// .filter(([key]) => {
// eachHit++;
// console.log(key)
// return attendanceGroupMembers.has(key);
// })
// .map(([_, members]) => {
// eachHit++;
// console.log('in map')
// return members;
// });
I would like to retain the myObject structure but with only the items found. Any idea how I can accomplish this?