Consider a const that holds an object with multiple levels like this:
const test = {
One: {
a: 220,
b: ['Chipotle', 'Subway', 'Habit Burger'],
},
Two: {
a: 110,
b: ['Chipotle'],
},
Three: {
a: 200,
b: ['Subway', 'Jack In The Box'],
},
Four: {
a: 460,
b: ['Chipotle', 'Subway', 'Habit Burger', 'Jack In The Box'],
},
};
I know that, for example, if I want to access the first object's a
value, I can say test.One.a
, but how do I programmatically access the value of test.One
, test.Two
, etc. without hardcoding it?