I just need to get a random number between 1 and 2 to assign my participants to their respective conditions.
I saw that random() was not working online, but math.random() does as it was mentionned on a previous post.
How do you actually implement it? I tried this for instance both the lines on the image, but they always say in the end that randomNumber is not defined (online).
random() should auto-translate properly PsychoPy to PsychoJS without the need to define in it a JS-code-component at the experiment begin with the current version of PsychoPy. So, the following code generates a random number between 1 and 2 (tested locally in a browser):
rand = random() + 1
In older versions of PsychoPy, you needed a JS-only code-component and defined at the begin of the experiment the function.