Code Component JS Translation error in the new update

Hi all,

I have a code segment in my experiment in which I have tried to calculate the total time taken by the respondents to complete my experiment.

I have no error that is causing any failure to run the experiment offline, and in the previous versions of Psychopy, the code line was getting easily converted into PsychoJS.

But since the recent update, the auto-conversion is reading as

/* Syntax Error: Fix Python code */

I am checking the total time using globalClock. The code line is below:

msg = "Total time : %.2f" %(globalClock.getTime()/60.0)

I know since the experiment is running fine, it won’t have any problem running offline, but I am certain this would create a problem when trying to push the experiment online.

I guess the question is, has there been a change in the syntax for the globalClock? Could someone help me out with the recent syntax for this code segment?

Thanks in advance!

You have never been able to use this type of string formatting in JavaScript, so it isn’t a recent change. Try.

msg = "Total time : " +str(round(globalClock.getTime()/60,2))

Hi @wakecarter ,

Yeah, as I said, I was initially doing it offline, so didn’t actively check for syntax errors for PsychoJS. Now that I am looking to push for it online, I am actively looking for the errors, and this popped up.

Thanks for the help!