Given two arrays:
const inputOne = [
{id: "valueA", prop: 123},
{id: "valueB", prop: 456}
]
const inputTwo = [
{id: "valueA", other: 54},
{id: "valueB", other: 98},
{id: "valueC", other: 11}
]
I'm trying to filter inputTwo
based on inputOne
's id
and then merge the properties found in both.
Desired output:
combinedAndFiltered = [
{id: "valueA", other: 54, prop: 123},
{id: "valueB", other: 98, prop: 456}
]
I've tried various combinations of map
, filter
and/or reduce
but somehow can't get my head around it.