I have two array
[{ Name: 'CVS 7201 Us Highway 64',Address: '7201 Us Highway 64',CustomerID: 'FB7BCE3B-E06E-420A-A342-08CF20054F78'},
{ Name: 'CVS 9931 Gilead Road', Address: '9931 Gilead Road',CustomerID: '920FAEF9-826B-4DE6-98F7-07E2201D5020'},
{ Name: 'Walgreens',Address: '2805 N Roosevelt Blvd',CustomerID: 'FB7BCE3B-E06E-420A-A342-08CF20054F78'}]
[{TenantID:1,External_ID:'920FAEF9-826B-4DE6-98F7-07E2201D5020'},
{TenantID:2,External_ID:'FB7BCE3B-E06E-420A-A342-08CF20054F78'}]
Filtered Data
[{ Name: 'CVS 7201 Us Highway 64',Address: '7201 Us Highway 64',TenantID:2},
{ Name: 'CVS 9931 Gilead Road', Address: '9931 Gilead Road',TenantID:1},
{ Name: 'Walgreens',Address: '2805 N Roosevelt Blvd',TenantID: 2}]
In my first array there are more then 5K record and in second array it's around 100+ I write some code but i am not happy with the way.
for (const data of recordset.recordset) {//5000
for(var i in lstAllTenant){//120
if(lstAllTenant[i].External_ID == data.CustomerID)
{
var pickupLocations = {
TenantID: lstAllTenant[i].TenantID,
Name: data.Name,
Address: data.Address,
}
lstPickupLocations.push(pickupLocations);
}
}
}
How can i optimize this thing?