I've got this:
var JSON = [
{
"id": 1,
"name1": "Seymore Butts",
"name2": "Jane Doe",
"name3": "John Smith",
"name4": "Mike Hawk"
}];
for (i = 1; i < 5; i++) {
var index = "name" + i;
window.console.log(JSON[0].index);
}
and of course it's getting undefined because it's looking for
JSON[0].index
instead of
JSON[0].name1
Any way to force it to evaluate the index var instead of just reading "index"?