0

I'm attempting to run a list of strings through an object. When I do it individually it works, but when I pass it through as a string it doesn't work. How would I fix this?

// this doesn't work
var a = "IntegrationItem1";
var data = faq.a; 

// but this works
var data = faq.IntegrationItem1; 

What's causing the first example to not work? Is the variable data seeing it as faq."IntegrationItem1" instead of faq.IntegrationItem1?

1
  • 4
    var data = faq[a]; Commented Nov 9, 2017 at 23:04

2 Answers 2

0

You can access properties of the object using it's names:

var a = "IntegrationItem1";
var data = faq[a];
Sign up to request clarification or add additional context in comments.

1 Comment

0

what you need is faq["IntegrationItem1"] => faq[a]

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.