Reputation: 37
I have an array like this:
var records:Array = new Array();
records.push({name:"nh", medinc:"66303"});
records.push({name:"ct", medinc:"65958"});
records.push({name:"nj", medinc:"65173"});
records.push({name:"md", medinc:"64596"});
etc...
for all 50 states. I am wondering if I can get the "medinc" data by using the "name" value? For instance, can I call the "nh" name value and get "66303" returned?
How can I do this?
Thank you for your help
Upvotes: 0
Views: 59
Reputation: 13532
Use an object instead to store the records then you can get the medinc directly using the name:
var records:Object = {};
records["nh"] = { medinc:"66303"};
records["ct"] = { medinc:"65958"};
records["nj"] = { medinc:"65173"};
records["md"] = { medinc:"64596"};
trace(records["nh"]["medinc"]);
Upvotes: 2