How to concat sub array in typescript or javascript? In may case I want concat all values
with same name
.
My array is
[
{
name: "AAA"
values: [[1573054321, 0], [1573054560, 0]]
}, {
name: "BBB"
values: [[1573054388, 0], [1573054596, 0]]
}
], [
{
name: "AAA"
values: [[1573054355, 0], [1573054542, 0]]
}, {
name: "BBB"
values: [[1573054325, 0], [1573054545, 0]]
}
]
I want this in my output:
[
{
name: "AAA"
values: [[1573054321, 0], [1573054560, 0], [1573054355, 0], [1573054542, 0]]
}, {
name: "BBB"
values: [[1573054388, 0], [1573054596, 0], [1573054325, 0], [1573054545, 0]]
}
]
My typescript exemple with a simple concat (allMetricSeries
is my input):
let metricSeries: MetricSeries[] = [];
allMetricSeries.forEach(metrics => {
metricSeries = metricSeries.concat(metrics);
});