const readings = [
{ location: { lat: '21.4', lng: '23.5' }, vehicle: 'sdkhf', id:'1' },
{ location: { lat: '22.4', lng: '25.5' }, vehicle: 'sdkhf', id:'2' },
{ location: { lat: '21.4', lng: '23.5' }, vehicle: 'sdkhf', id:'3' },
{ location: { lat: '22.4', lng: '25.5' }, vehicle: 'sdkhf', id:'2' },
{ location: { lat: '28.4', lng: '21.5' }, vehicle: 'sdkhf', id:'5' },
];
The task at hand is to group the array of objects above based on their location property.
The desired outcome consists of an array of objects that include the location and points (an array of objects with the same location).
This grouping operation can be achieved using either lodash or the array reduce method.