psychopy.org | Reference | Downloads | Github

How to check JavaScript code without deploying the experiment?

Auto-JS gives an error when converting Python code with string formatting, so based on some answers I read here I created my own JS code, just want to verify whether it works. Or how to test snippets of JS code locally?

msg2= "You got {0} out of {1} correct !".format(len(matched_words), stimuli_count[chosen_count-1])

I figured it out. For someone that still needs help on this issue, the following code works

msg2 = "You got " + String((matched_words).length) + " out of " + String(stimuli_count[chosen_count -1]) + " correct !"

Javascript can be tested locally through any browser console, so instead of running the experiment online, you can just work with the code snippet locally!

I’m working on adding a JS console to Coder view for stuff like this, probably won’t be in this coming release (2021.1) but may well make it to the summer release (2021.2) and will appear in the dev branch on GitHub sooner