I am faced with the task of updating the listOfStudents Object by matching it with the homeworkResults Object based on their corresponding email values. Through comparison, when the email matches between the two Objects, I aim to retrieve the topic and success values and update the listOfStudents Object. This task must be achieved solely using Javascript.
The expected outcome should resemble the following:
name: 'John',
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f09a9f989eb0979d91999cde939f9d">[email protected]</a>',
results: [
{
topic: 'HTML Basics',
success: true
},
{
topic: 'CSS Basics',
success: false
}
]
const listOfStudents = [
{
name: 'John',
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b0dadfd8def0d7ddd1d9dc9ed3dfdd">[email protected]</a>'
},
{
name: 'Jane',
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c9a3a8a7ac89aea4a8a0a5e7aaa6a4">[email protected]</a>'
}
];
const homeworkResults = [
{
topic: 'HTML Basics',
results: [
{
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2e444146406e49434f4742004d4143">[email protected]</a>',
success: true
},
{
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0e646f606b4e69636f6762206d6163">[email protected]</a>',
success: true
}
]
},
{
topic: 'CSS Basics',
results: [
{
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="83e9ecebedc3e4eee2eaefade0ecee">[email protected]</a>',
success: false
},
{
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4b212a252e0b2c262a222765282426">[email protected]</a>',
success: true
}
]
}
];