Currently, I am handling a project where I receive data in the form of an Object Array. My task is to merge values with the same key into one key and convert the values into an array of strings.
Below is the sample data I am working with:
inputArray = [
{
colors: 'Red',
size: 'Small'
},
{
colors: 'Blue',
size: 'Large'
},
{
colors: 'Red',
size: 'Large'
},
{
colors: 'Pink',
size: 'X-Large'
}
]
Here is the desired output :
outputArray = {
colors: ['Red','Blue','Pink'],
size: ['Large','X-Large','Small']
}