Crazy (?) behavior of JS code snippet in JS for online study

Dear all

I cannot find the error, so I am glad to get help.

In the beginning of (developing) web experiment I use the following:
// Begin Experiment
var cde = “CDE”;
instrCond = cde.substr(Math.floor(Math.random() * 3), 1);
instrFilename = (‘instruction’+instrCond+’.xlsx’);
var AB = “AB”
condition = AB.substr(Math.floor(Math.random() * 2), 1);
conditionFilename = (‘group’+condition+’.xlsx’);

When I try to run it, I get an error message saying that an error occurred while importing “instructionA.xlsx” (on other occasions also “instructionB.xlsx”). It is as if the two random choices get mixed. Interestingly, the python version of that code runs.

Any idea?

Edit: The owls are not what they seem

Probably the code is not the problem, but some unexpected behavior of PsychoPy Builder. It seems that the program is not updating everything to the newest version?

Edit again:

It is showing the same error when I fix my variable to a constant. Same error means it is stating that it is unable to load “instructionA.xlsx”.

I guess this is a leftover from a previous version of the builder file. Again, it is working in python, but not in (local debug mode) of JS.

Hey @gernot, sorry to hear PsychoPy is misbehaving on you, would it be possible to send me a .psyexp or link to your project repository? Here to help, thanks, s.