I have an array of arrays with date at index 0. I would love to check love to loop through the array and any date that matches with another, there values should be merged at.
this is what the array looks like and what i have tried..
var array = [
[
Date 2019-06-11T10:00:00.000Z,
0,
0,
0,
23
],
[
Date 019-06-11T10:00:00.000Z,
0,
0,
2,
0
],
[
Date 2019-16-11T12:00:00.000Z,
0,
56,
0,
0
],
[
Date 2019-16-11T12:00:00.000Z,
3,
0,
0,
0
]
]
var result = array.filter(function(v) {
return this[v[0]] ?
!Object.assign(this[v[0]], v) :
(this[v[0]] = v)
}, []);
console.log(result);
I intend the output to be something like this, but the method seems to remove the duplicates.
var array = [[
Date 2019-06-11T10:00:00.000Z,
0,
0,
2,
23
],[
Date 2019-16-11T12:00:00.000Z,
3,
56,
0,
0
]]