I want to create a new object with key/value pairs. The new object should include values from an existing key/value object as well as unique values from an array.
Here is the array:
[{ name: "Computer", name: "Car", name: "House", name: "Flower"}]
And here is the existing object:
{ computer: { title: 'Computer', color: 'Black' }, house: { title: 'House', color: 'Red' }}
To achieve this, the new object would look like:
{ computer: { title: 'Computer', color: 'Black' }, car: { title: 'Car', color:'' }, house: { title: 'House', color: 'Red' }, flower: { title: 'Flower', color:'' } }
What is the best way to do this? One approach could be to loop through the array, compare the values, and extract the unique ones. However, I am unsure how to implement this effectively.