I am working with an array of objects
const target = [{name: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="89fafbe2c9eee4e8e0e5a7eae6e4">[email protected]</a>', selected: false, alertType: 'max'},
{name: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1c7d7e7f5c7b717d7570327f73717573027577555c59717e72707077737e70735974787a">[email protected]</a>', selected: true, alertType: 'clear'},]
My goal is to update the array based on the name and alertType values. If a match is found, I will update the selected property. If no match is found, I will add a new object. Here's the new object:
const newObj = {name: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c1b2b3aa81a6aca0a8adefa2aeac">[email protected]</a>', selected: false, alertType: 'both'}