I need create one array based on two and more another arrays with unique keys each elements in array name of keys should be incremented This data is for plotting by Recharts but code below is incorrect, i got same value for each key
you can see demo https://jsfiddle.net/shuts13/hn52vpxf/
i have array of arrays:
const setOfArrays = [
[
{
'dateTime': 1531612800000,
'value': 97.0,
'rangeMin': 79.0,
'rangeMax': 110.0
},
{
'dateTime': 1531512800000,
'value': 96.0,
'rangeMin': 79.0,
'rangeMax': 110.0
}],
[{
'dateTime': 1544745600000,
'value': 82.7,
'goal': 77.0
},{
'dateTime': 1544745600000,
'value': 81,
'goal': 77.0
}],
[{
'dateTime': 1531612800000,
'value': 66.0,
'rangeMin': 50.0,
'rangeMax': 80.0
},{
'dateTime': 1531612800000,
'value': 65.0,
'rangeMin': 50.0,
'rangeMax': 80.0
}]
]
what i expected get on output
[
{
'dateTime': 1531612800000,
'value': 97.0,
'rangeMin': 79.0,
'rangeMax': 110.0,
'dateTime1': 1544745600000,
'value1': 82.7,
'goal1': 77.0,
'dateTime2': 1531612800000,
'value2': 66.0,
'rangeMin2': 50.0,
'rangeMax2': 80.0
},
{
'dateTime': 1531512800000,
'value': 96.0,
'rangeMin': 79.0,
'rangeMax': 110.0,
'dateTime1': 1544745600000,
'value1': 81,
'goal1': 77.0,
'dateTime2': 1531612800000,
'value2': 65.0,
'rangeMin2': 50.0,
'rangeMax2': 80.0
}
]
code what i had written is incorrect , value is duplicated, i dont know what is wrong
[{a: 1}, {a: 2}]be[{a: [1,2]}]instead of[{a:1, a2:2}]? That would be a lot easier to use.