| Reference | Downloads | Github

PsychJS break/pause in trials

I want the participants to have a break every 4 trials. In the BreakTime routine I have a code component which works in PsychoPy but not online. I have the following in the “Each Frame” tab:

if (trialsloop.thisN % 4 > 0):
    continueRoutine = False

With this code, they never see the break screen. I tried moving the code to the “Begin Routine” tab and they see the break screen after every trial. I’m guessing trialsloop.thisN is the problem, but what should it be?

Please look at my crib sheet.

All loops have to be referenced as trials in JS

As simple as that! Below is the change and now it’s working in PsychoPy and PsychoJS:

if (trials.thisN % 4 > 0) or (trials.thisN == 0):
    continueRoutine = False

Many thanks.