# Experiment code don't match actual code

**URL:** <https://discourse.psychopy.org/t/experiment-code-dont-match-actual-code/14995>\
**Category:** Online experiments\
**Created:** [July 12, 2020, 5:29am UTC](https://discourse.psychopy.org/t/experiment-code-dont-match-actual-code/14995 "2020-07-12T05:29:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackchen570](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@jackchen570](https://discourse.psychopy.org/u/jackchen570)\
**Post date:** [July 12, 2020, 5:29am UTC](https://discourse.psychopy.org/t/experiment-code-dont-match-actual-code/14995/1 "2020-07-12T05:29:34Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [July 12, 2020, 9:22pm UTC](https://discourse.psychopy.org/t/experiment-code-dont-match-actual-code/14995/2 "2020-07-12T21:22:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jackchen570](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@jackchen570](https://discourse.psychopy.org/u/jackchen570)\
**Post date:** [July 13, 2020, 5:22am UTC](https://discourse.psychopy.org/t/experiment-code-dont-match-actual-code/14995/3 "2020-07-13T05:22:31Z")

</div>

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
