My array contains dynamic elements within objects:
[
{
"Value1": [
"name",
"surname",
"age"
],
"Value2": [
"name"
],
"Value3": [
"name",
"age"
]
},
...
]
I am trying to consolidate the values from different keys into a single object as follows:
{
"Value1": [
"name",
"surname",
"age",
"hoursWorked",
"timeSpent"
],
...
}
I have attempted using array.reduce() without success due to the dynamic nature of the elements. Any assistance in solving this problem would be greatly appreciated.