To begin, I am not sure if this question will make much sense. I will do my best to explain.
I am working on a project looking at U.S. Census bureau information. The part of the object that I am looking at looks like this: (Please note that this is only part of the object.)
Object {MTFCC: "G5020", OID: 207903717468543, GEOID: "13135050431", STATE:
"13", COUNTY: "135"…}
AREALAND: 5416158
AREAWATER: 34463
B19013_001E: "45543"
The part that I am interested in is: B19013_001E which happens to be the code for Median Household Income. In order to get specifically the Median household income I would do:
response.features[1].properties.B19013_001E
Everything works find up to this point. However, my problem is the following: I want to change that code to have other values. So, if the individual wants to look for median_male_age, whose code is B01002_002E I do not want to hard code in B01002_002E as the following:
response.features[1].properties.B01002_002E
The above line would work. But again I want something that can be determined by a variable so that I will not have to hard code in the special code. So, I want a code that is like this: (just an example!)
var value = prompt("What do you want to look at: ")
//In this case value would be the special code like B01002_002E which the user enters.
console.log(response.features[1].properties.value)
Whenever I do this, I get no information back. At first I thought I had the wrong type but I do not believe that is the issue. (I tried converting to a number and back to a string etc.) Any help on this will be great!
console.log(response.features[1].properties[value])response.features[1].properties[propertyVar]