I have array anArray containing this:
var entry1 = ['variable1','X'];
var entry2 = ['variable2','Y'];
var entry3 = ['variable3','Z'];
var anArray = [entry1, entry2, entry3];
Now I would like to do the following:
var variable1 = ...
where the ... is supposed to be a piece of magic code which searches anArray with the name of the variable and returns the value 'X' (so that variable1 ends up with the value 'X'). If the name of the variable was variable2 it should end up with the value 'Y' etc.
Is this possible?
If it is not possible to get it done in quite as magic of a fashion that I am wishing for: what is the most compact code to get the value 'X' into variable1, 'Y' into variable2 etc. ?