My feedback message works fine when I run the experiment on my computer, but when I run it on Pavlovia, the feedback message is always “wrong.” I think it’s probably because I translated the python code incorrectly to js code. How would you translate the python code below to JS code? Thanks!
Here’s my python code for feedback:
if not key_resp.rt:
msg = 'Failed to respond'
elif key_resp.keys[-1]==corrAns:
msg = 'Correct!'
else:
msg = 'Wrong!'
Hi @CatK, your JS code is ok (from previous post), but its how you have set your correct answer variable - you need to set corrAns as a string rather than Number. This is because the JS code uses strict equality checks that do not ignore type, so a string and number can never be equal, even when comparing 1 vs “1”. So, if corrAns === 1 and resp_key.keys === 1, they will not be equal and you will not log a correct answer for your keyboard.
If you want to know more, look up strict vs loose (=== vs ==) equality checks in JavaScript.
Thank you! But after I changed the value of corrAns to string, it still doesn’t work. What else could be wrong? Or am I not changing the code correctly? Thanks (21.4 KB)
Thank you! But after I changed the value of corrAns to string, it still doesn’t work. What else could be wrong with my code? Or am I not changing the code correctly? Thanks!
Ok great, well that version you posted works for me, so I think perhaps you need to refresh your browser cache using CTRL + F5 (if using Windows) to get the most up to date version.