Combine 2 arrays, updating values : <p>In my reducer I am pulling down results from my API, I would like to combine this array with the persisted data from storage if it exists, the only fields that need to be overwritten in the data are <code>bookMarked</code>, <code>totalScore</code>, and <code>completed</code>. How can I compare arrays and overwrite the required properties if they are different?</p>

<p>What is the best way to do this?</p>

<pre><code>let arrayFromAPI= [
    {
        bookMarked: false,
        completed: false,
        totalScore: 50,
        current: 0,
        description:
            "&lt;p&gt;Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.&lt;/p&gt;",
        icon: "male-urinary-catheterisation",
        id: 1
    },
    {
        bookMarked: false,
        completed: false,
        totalScore: 50,
        current: 0,
        description:
            "&lt;p&gt;Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.&lt;/p&gt;",
        icon: "male-urinary-catheterisation",
        id: 2
    }
];

let arrayFromPersist = [
    {
        bookMarked: true,
        completed: false,
        totalScore: 50,
        completed: true,
        current: 0,
        description:
            "&lt;p&gt;Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.&lt;/p&gt;",
        icon: "male-urinary-catheterisation",
        id: 1
    },
    {
        bookMarked: true,
        completed: false,
        totalScore: 50,
        completed: true,
        current: 0,
        description:
            "&lt;p&gt;Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.&lt;/p&gt;",
        icon: "male-urinary-catheterisation",
        id: 2
    }
];
</code></pre>
