Builder - Uncaught SyntaxError: unexpected token

URL of experiment: Pavlovia

Description of the problem:
When piloting an online experiment based on builder, I got an Uncaught SyntaxError: unexpected token ‘)’ error. it works nicely locally, and I ran the online in the web browser (Chrome)

I tried to change the code component all into “both”. Since this experiment is built on the builder, it is unclear which line the error occurs.

Hi,

The error is with

 if (consentResp.keys == /* j */
        ) {

If j is your only allowed key for consentResp.keys, change it to [‘j’]

Maybe try the same if it’s your correct key

Thanks for your reply, it seems to works. But I got an error for nCorrect which I thought I defined in the Before experiment). any suggestion?

May I know why we make one value as a list (e.g., [‘j’]) for the correct answer whereas the leave the allowed keys without making it as a list (e.g., ‘j’,‘n’; it has more than one answers)? Thank you very much

image

You are defining it in Before Experiment. Define it in Begin Experiment.

I’m not entirely sure how PsychoPy views different parameters. The list of allowed keys can have square brackets round it.

The problem is now solved by changing the code type to JS from both

Please could you post what you put on each side of the Both component and mark it as the solution?

For both side the code should be:

nCorrect=0
msg=“”
Noted that it works for online study after changing the code type from “Both” to JS