Created
November 2, 2019 08:02
-
-
Save llcoollasa/a5e33066ebceb18147239cab85019d6f to your computer and use it in GitHub Desktop.
Object Compare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var accountUsers = [ | |
{_id:1, email:'email1'}, | |
{_id:2, email:'email2'}, | |
{_id:3, email:'email3'}, | |
{_id:4, email:'email4'}, | |
{_id:5, email:'email5'}, | |
]; | |
var calendarUsers = [ | |
{_id:1, email:'email1', status: 'pending'}, | |
{_id:2, email:'email2', status: 'active'}, | |
{_id:3, email:'email3', status: null}, | |
]; | |
// get eligible users for calendar user list | |
function comparer(arr){ | |
return function(cur) { | |
return arr.filter(a => a.email === cur.email).length == 0; | |
} | |
} | |
var eligibleList = accountUsers.filter(comparer(calendarUsers)); | |
console.log(eligibleList); | |
/* | |
[ | |
{ | |
"_id": 4, | |
"email": "email4" | |
}, | |
{ | |
"_id": 5, | |
"email": "email5" | |
} | |
] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment