I am trying to combine two arrays based on a shared property they both have. How can I do this in react? I want to combine them to create one array that contains the checkbox as well as all of the other items.
Here are two sample arrays:
const array1 = [
{Handle: "handle1", title: "handle1"},
{Handle: "handle2", title: "handle2"},
{Handle: "handle3", title: "handle3"} ]
const array2 = [
{Handle: "handle1", checkbox: true},
{Handle: "handle2", checkbox: false},
{Handle: "handle3", checkbox: true} ]
Result:
const array2 = [
{Handle: "handle1", checkbox: true, title:"handle1"},
{Handle: "handle2", checkbox: false, title:"handle2"},
{Handle: "handle3", checkbox: true, title:"handle3"} ]
How do I combine them in such a way that I get a new array that contains the handle, title and checkbox all in the right places?