I've created an array of objects from a csv file so:
var s=[];
d3.csv('income.csv', function(data) {
data.forEach(function(d, i) {
w={};
w.geoID= data[i]['GEO.id2'];
w.population = data[i]['HC01_EST_VC15'];
s.push(w);
})
})
console.log(s);
console.log(s[1].geoID);
console.log(s) reveals:
[]
0: Object { geoID: "Id2", population: "Households; Estimate; Mean income (dollars)" }
1: Object { geoID: "37001", population: "59084" }
2: Object { geoID: "37003", population: "52750" }
3: Object { geoID: "37005", population: "47715" }
4: Object { geoID: "37007", population: "45101" }
5: Object { geoID: "37009", population: "50702" }
6: Object { geoID: "37011", population: "56130" }
However, console.log(s[1].geoID) reveals:
undefined
What gives - aren't i merely calling the geoID key in index 1 of this array called 's'?