Normally I would write
arr = ['choiceA', 'choiceB', 'choiceC', 'choiceD', 'choiceE'];
position = 3;
answer = arr[position];
Just wondering…
Is it valid javascript to write the following?
Will it work cross browser?
answer = ['choiceA', 'choiceB', 'choiceC', 'choiceD', 'choiceE'][position];
Yes, it will. This sintax look weird in a first look, but it is perfectly valid. You are getting a position value from an array that is not being assigned to anything.