Here is the JSON object:
{
"stats":{
"ie":{
"9":"y",
"10":"y",
"11":"y"
},
"edge":{
"12":"y",
"13":"y",
"14":"y"
},
"firefox":{
"15":"y",
"16":"y",
"17":"y"
}
}
There is more data but this should give you an idea about the structure. This is my code:
var browsers = ["ie","edge","firefox"];
for (var i = 0; i < browsers.length; i++) {
var bStats = result.stats.browsers[i];
//Do something with it...
}
This gives me the error Uncaught TypeError: Cannot read property '0' of undefined
. If I directly use result.stats.ie
etc. everything works perfectly. How can I iterate through all this data properly?