Hi,
I'm using a loop to manipulate an object. I need each loop to use a succesive element in my JSON data. For example:
Loop 0 —> user.preference.0
Loop 1 —> user.preference.1
Loop 2 —> user.preference.2
Initially I thought I could simply use the loop's 'index' variable (which tracks the loop's current iteration number) in my JSON variable, such as user.preference.index. But I quickly realized that it's not possible to use a variable in another variable. (At least not like that.)
How can I reference a variable in another variable, is it possible? If not, is there another option that can allow me to increment my JSON data variable for each loop as described above?
Thank you!