I have the following variables: Test_0, Test_1 Test_2
Is it possible to concatenate the iteration value to some text in order to match the variable name?
Many thanks
for ( let i = 0; i < myArray; i++) {
Test_ + i.toString().setValue('some value");
}:
Are you saying that there is a variable Test_0 and it has a method setValue?
Then that would not work. You would need an array of variables and access them that way, or it could be an object of them and you dynamically create a property name. But you can’t dynamically create variable names like you seem to be trying there.
Correct!
Three variables Test_0, Test_1, Test_2 each with a method setValue
As the for loop iterates I wanted to dynamically change the variable name by concatenating (appending) the iteration number (value of i) to ‘Test_’.
I"ll try the array approach.
Many thanks for your help