Description of the problem: One of the pre-experiment questions is “Age in years”
I have tried several pieces of JavaScript code to quit experiment e.g.,
if int(expInfo[“Age in years”] >18
) {
psychoJS.quit({message: ‘Experiment terminated, Age out of range’});;
}
What I want to find is a piece of JS code that will terminate the experiment if the participant enters anything that is not a a string variable of the numbers between 18 and 120.
This code seems to be a mix of Python and JS, and has a bracket in the wrong position. You need to close int() before > 18.
Also do you want to quit when Age is 19+ ?
Add a console.log (print) command inside the brackets to check your quit code is being run at all, before wondering whether that is the source of the issue.