Skip to content

Instantly share code, notes, and snippets.

@chris-burkhardt
Last active July 15, 2021 03:22
Show Gist options
  • Save chris-burkhardt/db9f4a2cf3ca8d92ab83ea4af4d582a9 to your computer and use it in GitHub Desktop.
Save chris-burkhardt/db9f4a2cf3ca8d92ab83ea4af4d582a9 to your computer and use it in GitHub Desktop.
Match Arrays by IDs
const missingIDs = ['111111', '2222222'];
const existingUsers = [{
"System": "Test",
"Company Name": "Test Company",
"UU_UserName": "testuser",
"Active": 0,
"Ceased": 0,
"Unused": 4,
"UBO Surname1": "Test",
"UBO Firstname1": "Test",
"UBO Address1": "10 Test Court",
"UBO Postcode1": 3150,
"UBO City1": "VIC",
"UBO Country1": "Australia",
"UU_ID": 111111
},
{
"System": "Test2",
"Company Name": "Test Company2",
"UU_UserName": "testuser2",
"Active": 0,
"Ceased": 0,
"Unused": 4,
"UBO Surname1": "Test2",
"UBO Firstname1": "Test2",
"UBO Address1": "102 Test Court",
"UBO Postcode1": 3150,
"UBO City1": "VIC",
"UBO Country1": "Australia",
"UU_ID": 2222222
},
]
let missingUsers = [];
existingUsers.forEach(user => {
if (missingIDs.find(id => parseInt(id) === user.UU_ID)) {
missingUsers.push(user)
}
})
console.log(missingUsers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment