Find centerpoint of polygon in JavaScript
I have a "place" object from Google Maps which has a set of coordinates that represent a bounding box for a given location, say London. Each set of coordinates has a latitude and longitude. I have written the below code to find the centerpoint, but I am not sure if it does actually produce the centerpoint. What if the polygon has 5 points instead of 4? Also, can this be done in a more efficient way, with less operations? function average(array) { // Add together and then divide by the length return _.reduce(array, function (sum, num) { return sum + num; }, 0) / array.length; } // I have a two