I came across a confusing fact during coding a script.
How can i find the variable which is equal to the value of another variable. THEN , get the value of that variable.
Here's an example:
var result;
var 1 = "john";
var 2 = "amy";
var 3 = "micheal";
var info = "1";
When var info is set to 1
, the script will then look for variable 1 which has the value JOHN
then get the value john
. Then set the result's value to "john".
For the same thing ,
When var info is set to 2
, the script will then look for variable 2 which has the value AMY
then get the value amy
. Then set the result's value to "amy".
and so on..
My info variable's value is not determined. it could be 1 , 2 or 3 which is set/determined by an user event.
P/S i can use if and else , but i want to know how this can be done. :)
So how can i do this?