Last active
July 15, 2021 03:22
-
-
Save chris-burkhardt/db9f4a2cf3ca8d92ab83ea4af4d582a9 to your computer and use it in GitHub Desktop.
Match Arrays by IDs
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
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