coordinates is an object. Objects in javascript do not, by default, have a length property. Some objects have a length property:
"a string - length is the number of characters".length
['an array', 'length is the number of elements'].length
(function(a, b) { "a function - length is the number of parameters" }).length
You are probably trying to find the number of keys in your object, which can be done via Object.keys():
var keyCount = Object.keys(coordinates).length;
Be careful, as a length property can be added to any object:
var confusingObject = { length: 100 };