TypeError: state.toLowerCase is not a function

I’d need to get a better idea of your error messages. Please could you set your experiment to running and send me the link?

Url: https://pavlovia.org/run/ablument/threat_detection_v1

Thank you.

Please could you show me a screenshot of the contents of textbox_3 ?

I haven’t yet successfully used editable text boxes online.

It might be worth changing your Text and Padding to Constant rather than Set Every Repeat.

However, the error you are getting is similar to a manual translation I have to do when making editable text boxes in code.

Python .upper() translates to JavaScript .toUpperCase()

According to Error with textbox: TypeError: state.toLowerCase is not a function - #8 by kellycotton it should work in 2020.2.10 so perhaps you are still running an earlier version.

I originally had it as Constant and changed it because of the warning “looks like your variable ‘null’ in ‘padding’ should be set to update”. Either way it doesn’t work and same error.

I am running the most updated version (I too was hoping that would fix it).

Should I try adding that manual translation to a Code component in that routine?

I don’t understand why, but the solution for me with this error was to set nReps = 1 (instead of blank) for the loop that had textbox routines, and a loop before it.

Why did you have a loop with blank nReps?

I must have removed the default (I think it is 5?) and left it blank since I only needed 1 repetition, and it worked locally so I didn’t realize that was the problem FOREVER.

So I’m having this problem when trying to run my experiment online after adding a textbox (typeError: state.toLowerCase is not a function). I have version 2020.2.10 and no loops with empty nReps. Any pointers or updates on this?

Do you have any loops with something other than digits in nReps?

Are you using an editable text component?

Do you have Array.prototype.append = [].push; in code_JS?

No loops with something other than digits in nReps (only one loop where nReps = 5)

I have a editable Textbox component (after adding this is when the problem started)

And yes, I do have Array.prototype.append = [].push; in JScode begin experiment.

Try removing Array.prototype.append = [].push;

The issue might be that it is already included in the editable text box.

I tried removing that and got TypeError: dot_dist_list.append is not a function

also tried using + to append my list (after removing the append to push bit), but then got TypeError: arr.reduce is not a function
which I expected something to go wrong since using + to append lists is under the “don’t do” column in the crib list.

(I have sum = (arr) => arr.reduce((a,b)=>a+b) in JScode where Array.prototype.append = [].push; also was)

also in case it matters, the editable textbox is in a separate routine after the trial that is looped over, contains the JScode, and requires the list appending.

Have you tried removing append = push and then manually changing append to push in the JS sides of the relevant code components (changing auto to both)

Ah, well after doing that the error is gone/no crashing! But while my Textbox now appears, it is not actually editable…

Ah, no, actually it is working (was a separate issue with the textbox), thanks!

So to sum up.

Array.prototype.append = [].push; in code_JS is incompatible with an editable text box in PsychoPy 2020.2. Version 2021 is untested as is whether having an editable text box prior to the first use of append means that you don’t have to manually replace append with push in code components.

Does that match your experience?