| Reference | Downloads | Github

How to translate PsychoPy to JavaScript


I’m trying to get this code working on pavlovia, but apparently I need to change it into a JS code first.
In this routine offers by three other players and one’s own offers are displayed on the screen as well as the overall credit number. The values (offer 1-4) are taken from an excel sheet.

other_offer_1.setText(u’ Player 1: %.0f Credits.’ %(offer1))
other_offer_2.setText(u’ Player 2: %.0f Credits.’ %(offer2))
other_offer_3.setText(u’ Player 3: %.0f Credits.’ %(offer3))
own_offer_1.setText(u’ Your: %.0f Credits.’ %(ownoffer))
pool_number.setText(u’ Pool is %.0f Credits.’ %(ownoffer+offer1+offer2+offer3))

Any idea what has to change to make it work on JS? I tried adding “var” and searched for other codes than “setText”, but none of this worked so far.

I’d appreciate any help.

Hi @rebecca.shane, you can use string concatenation in JavaScript:

other_offer_1.text = "Player 1: " + Math.round(offer1) + " credits."

Thank you very much for your help! I will try this.