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 bookMarked, totalScore, and completed. How can I compare arrays and overwrite the required properties if they are different?
What is the best way to do this?
let arrayFromAPI= [
{
bookMarked: false,
completed: false,
totalScore: 50,
current: 0,
description:
"<p>Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.</p>",
icon: "male-urinary-catheterisation",
id: 1
},
{
bookMarked: false,
completed: false,
totalScore: 50,
current: 0,
description:
"<p>Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.</p>",
icon: "male-urinary-catheterisation",
id: 2
}
];
let arrayFromPersist = [
{
bookMarked: true,
completed: false,
totalScore: 50,
completed: true,
current: 0,
description:
"<p>Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.</p>",
icon: "male-urinary-catheterisation",
id: 1
},
{
bookMarked: true,
completed: false,
totalScore: 50,
completed: true,
current: 0,
description:
"<p>Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.</p>",
icon: "male-urinary-catheterisation",
id: 2
}
];