I have the following objects:
const allMembers = {
"-Lz8YxHiwp8QZW3TqAFn": {
"first": "foo",
"last": "bar",
"uid": "-Lz8YxHiwp8QZW3TqAFn"
},
"-Lz8YxHqQXWoaGOFRLrO": {
"first": "foo",
"last": "bar",
"uid": "-Lz8YxHqQXWoaGOFRLrO"
},
"-Lz8YxHsMItaaTVNyQRE": {
"first": "foo",
"last": "bar",
"uid": "-Lz8YxHsMItaaTVNyQRE"
},
"-Lz8YxHwuVBMWl0Go6C5": {
"first": "foo",
"last": "bar",
"uid": "-Lz8YxHwuVBMWl0Go6C5"
},
"-Lz8YxHy0S-QkDaE1PkX": {
"first": "foo",
"last": "bar",
"uid": "-Lz8YxHy0S-QkDaE1PkX"
},
}
const attendanceData = {
"-Lz8YxHiwp8QZW3TqAFn": true,
"-Lz8YxHqQXWoaGOFRLrO": true,
"-Lz8YxHsMItaaTVNyQRE": true,
"-Lz8YxHwuVBMWl0Go6C5": false,
"-Lz8YxHy0S-QkDaE1PkX": true,
"-Lz8YxIFA1XGVmaNfNr3": false,
"-Lz8YxIJVZnIIj7RgEzg": false,
}
I need to clean up the allMembers to only return if it's found as true in attendanceData. Here is my attempt but it's obviously not working. Also the way I'm doing it has to loop the first one over the other times.
const membersHere = Object.keys(allMembers).filter(memEl => Object.keys(attendanceData).find(attendEl => memEl == attendEl));