psychopy.org | Reference | Downloads | Github

Pavlovia error - Cannot read property '0' of undefined

URL of experiment: Sign in · GitLab

Description of the problem: Hello all, it’s going to be pretty straightforward. I get this error even though I don’t have anything set to ‘0’


What should I do?

The issue is, I believe, that there is a problem with ite1_loop

Do you have nReps sent to blank?

You mean set* to? No, I don’t.
The first line in the following code seems to be the problematic line. Does js starts from 0 in its for loops and throws the error 0 is not defined?
By the way, the same code structure was executed without a problem for an earlier loop in which I defined nReps with number rather than a variable name from xlsx. Can that be a problem?

  for (const thisIte1_loop of ite1_loop) {
    const snapshot = ite1_loop.getSnapshot();
    thisScheduler.add(importConditions(snapshot));
    thisScheduler.add(iteration1RoutineBegin(snapshot));
    thisScheduler.add(iteration1RoutineEachFrame(snapshot));
    thisScheduler.add(iteration1RoutineEnd(snapshot));
    thisScheduler.add(endLoopIteration(thisScheduler, snapshot));
  }

I think nReps is the issue.

Did you put a $ in front of the variable name?

If the $ is shown in the PsychoPy dialogue box it probably isn’t needed in PsychoPy and may cause an error online.

I noticed that and removed the $ signs. That solved my trialNum (nReps variable name) undefined issue. Thanks.

Though I solved this post’s problem too I really don’t understand why. :smiley:

I have 7 routines nested in loops. All their nReps come from an xlsx file. The first routine threw the error 0 undefined, so I changed nReps to a number instead of a variable from excel, but I only did this for the first routine to see if that’s the problem. It worked and I didn’t even have to touch the other 6 routines.