Appending corresponding stimuli of dictionary to list online

URL of experiment: Pavlovia

Description of the problem:

I am currently programming an online experiment where children need to indicate whether the sound they hear corresponds to the symbol they see (by pressing left or right button).

The experiment runs but no symbols are presented.
Looking at the data reveals that there goes something wrong with appending symbols to the symbollist (which is used to loop through when presenting the symbollist).
More specifically, the symbollist is empty.

What you need to know:
The soundlist is defined beforehand and a congruency_list defines whether a corresponding or non-corresponding symbol should be presented.
For this, I used a dictionary in psychopy which worked well, but seems that there goes something wrong when translating it to js.

I used the following code:

for (var el = 0, _pj_a = num_items_congr; (el < _pj_a); el += 1) {
    if ((congruency_list[el] === 1)) {
    } else {
        if ((congruency_list[el] === 2)) {
            while ((symbol_list[el] === stimuluslist4[sound_list[el]])) {
                symbol_list[el] = randomChoice(symbols1_8);

So, if congruency = 1, I want to append the symbollist with the symbol corresponding to the presented sound (based on the dictionary).
If congruency = 2, I want to append the symbollist with a non-corresponding symbol that is randomly chosen (and not the corresponding).

The function randomChoice is defined before, as well as the append-push translation.


And I used this code to define the dictionary:

var stimuluslist4 = {"AllStimuli/1.mp3": "AllStimuli/1.png", "AllStimuli/2.mp3": "AllStimuli/2.png", "AllStimuli/3.mp3": "AllStimuli/3.png", "AllStimuli/4.mp3": "AllStimuli/4.png", "AllStimuli/5.mp3": "AllStimuli/5.png", "AllStimuli/6.mp3": "AllStimuli/6.png", "AllStimuli/7.mp3": "AllStimuli/7.png", "AllStimuli/8.mp3": "AllStimuli/8.png"};

Hey Cara,

A good first step in figuring out what’s going wrong is logging some stuff to the console. This way you can, for example, check whether the loop is behaving as you’d expect. See this tutorial for some intro into the console. Thomas Pronk / tutorial_js_expose_psychojs · GitLab

Best, Thomas