Created
July 13, 2017 05:32
-
-
Save reggie3/440348a2e780700591e3977eb979ffac to your computer and use it in GitHub Desktop.
Write distance results
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case 'WRITE_DISTANCE_RESULTS': | |
return locations.map((location) => { | |
if (location.ID === action.ID) { | |
let distances = [action.distance].concat(location.distances); | |
distances = distances.slice(0, action.locationArrayMaxLength); | |
let distanceAverage = distances.reduce(function (sum, value) { | |
return sum + value; | |
}, 0) / distances.length; | |
return Object.assign({}, | |
location, | |
{ | |
distances, | |
distanceAverage | |
}); | |
} | |
return location; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment