0

I know this question has been asked a million times, I just can't seem to make the answers I find fix my problem. All I'm trying to do is return the Value of the key that is specified. They Key is in the variable "t":

RefDataTables.forEach(function(t, ti) {
  response.body = JSON.stringify(RefData_UpdateTracker.response.data[0].t);
});

I know the ".t" is wrong because that is looking for a property (I'm not sure the right word to call it) named "t"

Since "t = "HandleType"" What I'm trying to accomplish is the equivalent of:

response.body = JSON.stringify(RefData_UpdateTracker.response.data[0].HandleType)
DarbyM
  • 1,173
  • 2
  • 9
  • 25

1 Answers1

1

You can access it by passing the variable between the square brackets.

response.body = JSON.stringify(RefData_UpdateTracker.response.data[0][t])
Gregor Menih
  • 5,036
  • 14
  • 44
  • 66
  • Thankyou! I kept thinking a "." was needed between the [] brackets, and kept trying it that way (data[0].[t]) Never tried it like you put. That was the trick. And makes sense now that I think about it. – DarbyM Feb 15 '16 at 17:57