Pavlovia experiment stuck on "initializing the experiment" page

URL of experiment: https://gitlab.pavlovia.org/Mi_Lab/kate_testing_cbb

Description of the problem:

I know this topic has been discussed previously, but I’m encountering an issue where I get stuck on the initializing page when attempting to pilot my experiment. Based on previous users’ experiences, I figured there was an error in my JS script which I attempted to resolve by viewing the JavaScript console. It looks the error causing this issue is "Uncaught SyntaxError: Unexpected token ‘&&’. I am fairly new to coding, so I’m not sure if this is accurate, but I think that the console is indicating that the error is occurring in line 1236 (this is what I see on the right side of the console: /Mi_Lab/kate_testing…Testing_CBB.js:1236). I am very confused because this line does not include any &&, or any syntax that would require && to be used.

I was hoping someone would be able to take a look at my repository and help me figure out what is going on here. Thank you so much in advance!

Hi Kate,
When you export to html/sync you should see any JS related errors in the PsychoPy runner. It usually refers to which code part of a code snippet e.g. Beginning Routine/End Routine the syntax error is. So have a look at your code snippets and probably the first instance of using &&.

The line of the error is not exact. In my experience the error occurs around that position. I’m afraid your experiment doesn’t seem to be public so nobody can review your code.

Cheers,
Julia

Hi Julia,

Thank you so much for your fast response! I have changed the visibility settings to public so hopefully that can be accessed now. Before I posted here I was getting errors upon exporting my experiment in PsychoPy that related to some code that I wrote for scoring an old/new part of my experiment, which have now been fixed (I think). I’m not getting any errors now when I export to HTML but I am still stuck on the initializing page.

Hi Kate,

I had a quick look at your .js file. In your code component at the end of your routine P2_Practice_YN in line 1335

if (Prac2_OldNew_key_resp.keys == ‘q’ && PP2qp == ‘q’)
{
Prac2_OldNew_key_resp.score = “H”;
Prac2_OldNew_key_resp.hCount += 1;
}
else if (Prac2_OldNew_key_resp.keys == ‘p’ && PP2qp == ‘p’)
{
Prac2_OldNew_key_resp.score = “CR”;
Prac2_OldNew_key_resp.crCount +=1;
}
else if (Prac2_OldNew_key_resp.keys == ‘q’ && PP2qp == ‘p’)
{
Prac2_OldNew_key_resp.score = “FA”;
Prac2_OldNew_key_resp.faCount +=1;
}
else if (Prac2_OldNew_key_resp.keys == ‘p’ && PP2qp == ‘q’)
{
Prac2_OldNew_key_resp.score = “M”;
Prac2_OldNew_key_resp.mCount += 1;
}

I noticed that you need to use ‘===’ instead of ‘==’. That’s just how Javascript works. So I recommend that you adjust your code components accordingly and see whether it makes a difference :slight_smile:

Hi Julia,

I figured it was something to do with the syntax! Unfortunately I have tried adjusting this and am still getting the same error. The weird thing is that this is the second time I have uploaded this exact experiment, and I was having no problems with piloting before even with using ‘==’ instead of ‘===’. I appreciate you taking the time to look at my code!