customerItems: [
{
label: "itemA",
serialNumber: 123
},
{
label: "testItem",
serialNumber: 44
}
]
otherItems: [
{
label: "anotherItem",
serialNumber: 44
},
{
label: "testItem",
serialNumber: 21
}
]
I am interested in looping through customerItems
, which is an array of objects. My goal is to filter the customerItems
based on whether their serial number matches an item in another array of objects called otherItems
. For instance, the desired result in this case should be:
{
label: "testItem",
serialNumber: 44
}
since otherItems
has a matching serialNumber
of 44.
I considered iterating through otherItems
and creating an array of serial numbers, then looping through that using forEach
, but I feel like there may be a more efficient way to achieve this.