Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Setting variable names dynamically using JS

Hey Guys,

I'm right now setting up an experiment where I need to dynamically define text stimuli presented in a sketchpad. The stimuli all come from three different lists and are placed on the sketchpad dependent on their list location. To prepare the stimuli for the visual presentation on the sketchpad I need to dynamically create variables - where the variable name is depending on the location list and the specific place inside the list. Yet I managed to do so in python using a var.set() command. Now as I try to set the experiment up online I'm having some trouble translating my python solution to JS.

Here is a code snipped of the python solution, followed by my current JS approach:

As you can see what I yet have tried is to define the name variable as a list and then try to use it's content (content) as a variable name. Though this does not work - probably because all it does is to overwrite the content of the name (variable rank_var_name[0]).

Do you have any suggestion how I can set the variable names to the content of my name variable (rank_var_name) in javascript?


Thanks in advance,

Leo

Comments

Sign In or Register to comment.