I have two arrays of dictionaries that look something like this:
var lat = [{key:"2017-09-20T11:51:32.000Z", value:50.7825333},{key:"2017-09-20T11:51:33.000Z", value:50.7826},...];
var lon = [{key:"2017-09-20T11:51:32.000Z", value:-1.3075833},{key:"2017-09-20T11:51:33.000Z", value:-1.3076},...];
You may have guessed that this is an array of latitudes and one of longitudes!
I would like an elegant way to merge time, lat, lon into one array. Both arrays contain the same keys (I have to check that this is always the case!).
var latLon = [{time:"2017-09-20T11:51:32.000Z", lat:50.7825333, lon:-1.3075833},...]
I chose something collaborative that works, but not very (i.e., iterate over both arrays and add to a new one), but it looks like there should be a more stylish way for Object.assign to use some nice lams. I also use the D3.js library if it contains useful methods.
source
share