Saving Data from Coder in Pavlovia

Hello everyone,
I coded parts of my experiment in the “Code”-component und have created a list, that has “nonword” in it. I shuffle this list and then save each position in the list as a new variable.
For example, like this (things are coded JS-conform, given that I want to run the study online)

nonwort_zeichen = ["uwimo", "botuy","isuge", "oxura"]
shuffle(nonwort_zeichen)

nonwort1 = nonwort_zeichen[0]
nonwort2 = nonwort_zeichen[1]
nonwort3 = nonwort_zeichen[2]
nonwort4 = nonwort_zeichen[3]

Text21 = nonwort1;
Text22 = nonwort2;
Text23 = nonwort3;
Text24 = nonwort4;

Because I also have other variables, it is nessesarcy to have the “Text21=nonwort1”. In PsychoPy builder I then use the text-component and as the text use “$Text21” etc.

The experiment is run online (through Pavlovia) but the data that is saved afterward is mostly empty and doesn´t show anywhere, what stimuli was presented as “Text21” etc.

Can anyone tell me, how I achieve the saving of this so that I can later on see, what variables/stimuli where shown?

Thanks in advance
Annalena

Are you using jsPsych or PsychoPy Builder with a code component (and therefore PsychoJS)?

In PsychoPy you can save data using

thisExp.addData('nonwort1',nonwort1)

I am using the code-component in the PsychoPy Builder. Code type is “JS” (as the “auto to JS” oftentimes doesn´t really work)

I would recommend that you use Auto whenever possible. There are only a few instances where you need to switch to Both and edit the JS manually. If you type my code into an auto component you will see the correct JS code, which you can copy and paste into your JS component if you want to stick with using them.

Thank you so much, I actually tried this and it worked. For anyone reading this and wondering what the JS-Code would be, it is:

psychoJS.experiment.addData("nonwort1", nonwort1);

Thanks again.