I have a Javascript object called Data that looks like:
Object {
zip: Array[14631],
lat: Array[14631],
lng: Array[14631],
surge: Array[14631]
}
Data looks like
Zipcode, Lat, Lng, Surge
10025, 47.323, -93.43, 1.7
So to access elements I can do something like:
data['zip'][i] and it will return the 'ith' element of the zip array.
I can do the same with all the arrays.
What I want is a data structure such that I can do:
data[10025] and it will return all matching element in the other arrays.
So lets say I had 5 entries with zipcode = 10025, the data[10025] would return:
10025,lat_1,lng_1,surge_1
10025,lat_2,lng_2,surge_2
10025,lat_3,lng_3,surge_3
10025,lat_4,lng_4,surge_4
10025,lat_5,lng_5,surge_5
So that I could then double iterate through
for zip in data['zip']{
for i in data[zip] {
print data[zip]['lats'][i]
}
}
I think this is a simple enough problem but I don't have much experience with javascript and can't seem to get it. Any help is much appreciated.
Another way to phrase this is I would like an object that looks like:
data[array size of N]
Where each element of that array holds 3 arrays of size M