I have variables such as app.figures.data[0].user.x0
, app.figures.data[0].user.y1
, and app.figures.data[0].user.d2
. These variables were assigned values.
There are a dynamic number of these variables following the order of incrementing the final number in the variable (ie: The next variable after app.figures.data[0].user.d2
is app.figures.data[0].user.x3
).
I am trying to determine an efficient way to get the value of each variable dynamically in a loop.
for(j = 0; j < len; j++){
var x = 'x' + j;
j++;
var y = 'y' + j;
j++;
var d = 'd' + j;
var dresult = app.figures.data[0].user.d;
}
I need the value of dresult
as it was for app.figures.data[0].user.d2
. For example, app.figures.data[0].user.d2
is 23
so dresult
should be 23
on that iteration.
I am new to JS so any suggestions are appreciated.