After line:
var geocodeCallBack = function (results, status) {
results
is object with properties results, success
, for example Object {results: Array[1], status: "OK"}
so the line:
locations[addressIndex] = results[0];
has to be changed to
locations[addressIndex] = results.results[0];