My task is to determine if the first argument includes the second one within an array of objects. Here is the example scenario:
whatIsInAName(
[
{ first: "Romeo", last: "Montague" },
{ first: "Mercutio", last: null },
{ first: "Tybalt", last: "Capulet" }
],
{ last: "Capulet" });
I encountered a roadblock because I cannot utilize the includes()
method since it's meant for arrays and not objects. Initially, I attempted to convert the objects in the whatIsInAName
function into arrays using Object.entries()
, but unfortunately, that approach did not yield the desired results. Now, I am contemplating two options - either transforming the objects into arrays or seeking an alternative method that can be applied to objects instead of the unavailable includes()
method.
Are there any suggestions or insights you could offer on this matter?
Appreciate your help!