TypeError when starting a specific condition loop

URL of experiment: Sign in · GitLab

PsychoPy Version: 3.2

Description of the problem: My experiment is a matching task, where participants have to match objects, expiry dates or full names before matching faces (the order by which these conditions come first varies based on randomisation embedded in the Javascript code). However, when I finish the practice trials of the OBJECT condition and go onto the actual trial section, I receive the following error:

TypeError: Cannot assign to read only property ‘undefined’ of object ‘#’

This error does not occur with my other two conditions. The main difference between the OBJECT condition and the NAME/DATE conditions is that several components (mostly text) are set to an opacity of 0 (which is written in my CSV files) - otherwise, the routine setup is exactly the same.

I have some experience with debugging JS script, but the debugging section of Chrome hasn’t really been able to give me anything informative to work off - the CSV files for my object condition are almost identical to my two other conditions, and I’m really confused as to where to start (console log shown below):

Any help would be appreciated!

This error has been fixed!

I interpreted the error as a “window” (global) variable not being defined. Javascript is very particular about local/global variables. At the start of the experiment, all variables are automatically loaded into Pavlovia as global variables with no value. Code components inserted into the Builder view of PsychoPy are loaded in as functions, and any variables you declare/modify within a code component are done at the local level.

Not quite sure how I fixed my error specifically, but I have several code components with Javascript code in it, and I noticed a few things:

  • Error would only pop up if OBJECT condition came first.
  • In one of my “if” loops, I did not declare a variable using “var” (unlike Python script, JS objects need to be declared using “var”, “let” or “const”);
  • After fixing the problem, this error would appear again on version 3.1 but NOT on version 3.2.