Hi there,
I have a very simple problem I think but I can’t seem to figure it out…
I have a practice loop of 10 trials (trial loop) where I count the correct answers (e.g. name: pracLoop, loopType: sequential, is trials: ticked, csv file used to load conditions). I have an outer loop surrounding this that has no conditions (name: Practice_rounds, loopType: sequential, is trials: not ticked, no parameters set).
I want a participant to complete the practice trials until they get at least 6 correct answers, or if the loop has repeated 3 times, so then break the Practice_rounds loop. In Python this is all working fine with the following code:
In begin experiment:
‘’’
PLoopTally = 0
PCorrs = 0
‘’’
In begin routine:
‘’’
if PLoopTally >= 3:
Practice_rounds.finished = True
msg = “Well done!”
elif PCorrs >= 6:
Practice_rounds.finished = True
msg = “Well done!”
else:
PLoopTally = PLoopTally + 1
PCorrs = 0
msg = “Let’s try that one more time!”
‘’’
I tried to code this in Javascript as follows:
In begin experiment:
‘’’
PLoopTally = 0;
PCorrs = 0;
‘’’
Tried in both Begin routine and End routine:
‘’’
if (PLoopTally >= 3) {
trials.finished = true;
continueRoutine = false;
msg = “Well done!”;
} else if (PCorrs >= 4) {
trials.finished = true;
continueRoutine = false;
} else {
PLoopTally = PLoopTally + 1;
PCorrs = 0;
}
‘’’
I have tried loopname.finished in JS, trials.finished and continueRoutine = false, but none of them seem to exit the loop.
Could anybody give me any tips on how I might be able to conditionally break out of the Practice rounds loop?