psychopy.org | Reference | Downloads | Github

Experiment code don't match actual code

Hi,
I’ve been having trouble with this for a little while now. Hopefully, someone will have better insight into this than I have. I am very much a beginner when it comes to pavlovia, github and the such so any help would be greatly appreciated.

I have the code below written for my online experiment that checks for undefined in key_Resp:
if(typeof key_Resp.keys !== ‘undefined’){
if (key_Resp.keys.length > 0 && key_Resp.keys.length !== Text.len) {
Other code omitted for simplicity};
Text.len = key_Resp.keys.length;
};

This is because key_Resp.keys starts out undefined which can throw off key_Resp.keys.length (I think). However, when I tried to pilot the experiment, I get the error TypeError: Cannot read property ‘length’ of type undefined. Chrome has the option to reveal the code that caused the error in source, which came back as below. The initial check for undefined disappeared. :

if (key_Resp.keys.length > 0 && key_Resp.keys.length !== Text.len) {
Other code omitted for simplicity};
Text.len = key_Resp.keys.length;

My problems is, the files in git was correct, it had the check for undefined. I even tried deleting the repository and re-upload my experiment but nothing worked. The check for undefined just wasn’t there. Would anyone have any idea why this may be?

That sounds like a cache issue. Have a look at my crib sheet for how to clear the cache in the console.

Best wishes

Wakefield

Thank you for the response. Clearing the cache worked wonders. It seems that I just have to clear cache every time I make a change.

Thank you so much for your help!
Jack