My array looks like this:
var array = [
['fred', 123, 424],
['johnny', 111, 222]
]
etc...
I simply would like to select the second value in the first array (123, i.e. the value in the "fred" array) like so:
array[0][1];
But it's returning undefined. When I do console.log(array), I get the following:
Array[1], Array[1], Array[1], Array[1]]
0: Array[3]
0: "fred"
1: 123
2: 424
etc...
How do I get the value of that second item using the syntax described above?
Thanks!
Here is the full code:
var addresses = [
['Bondi Beach Australia'],
['Coogee Beach Australia'],
['Cronulla Beach Australia'],
['Manly Beach Australia']
];
for (i = 0; i < addresses.length; i++) {
(function(address){
geocoder.geocode( { 'address': addresses[i][0]}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
address.push(results[0].geometry.location.lb);
address.push(results[0].geometry.location.mb);
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
})(addresses[i]);
}
console.log(addresses[0][1]); // Returns 'undefined'