Code component from python to JS

Hi all,
I am making an experiment with the builder in the purpose to put it into Pavlovia. I am a very beginner in psychopy and I really don’t know how to code in JS.
Here is the little code component I added to my script. Can you help me coding this into JS?

if slider_RecoYeux.getRating() == 1:
doBranching = 1
else:
doBranching = 0

Thanks a lot in advance,
MT

Hi,

I’m not an expert myself and I’m struggling as well with JS and Pavlovia. In the code component you can automatically traslate between Python and JS (using Auto -> JS).
This is the automatic translation i got entering your code:

if ((slider_RecoYeux.getRating() === 1)) {
doBranching = 1;
} else {
doBranching = 0;
}

Sometimes the translation is not perfect, I suggest you check the document “Python to JavaScript Crib Sheet” that you can find in other threads

1 Like

It works, thank you so much!