Imagine having two entities like the following:
const obj1 = {key1: "", key2: "", key3: ""};
const array2 = [
{
name: "key1",
}]
Is there a way to verify if array2
contains an object with the same name as each field in obj1
?
In essence, I want to transform array2
into this form:
const array2 = [
{
name: "key1",
},
{
name: "key2",
},
{
name: "key3",
}]