I am trying to get a property value of a Javascript object.
My code goes like this:
for (key in map.regions) {
console.log(key);
console.log(states);
console.log(states.key);
}
The variable key will be something like, "US-VA"
The variable states should look something like this:
Object {US-VA: Object, US-PA: Object, US-TN: Object, US-ID: Object, US-NV: Object…}
(This is from Chrome).
However whenever I use console.log on states.key - which should get the object that the key represents, I instead get undefined.
What am I doing wrong here? How do I get the values from the states variable that correspond with the value in key?