Randomization code not working online

I have some code that I found on here that basically allows me to take two columns in an excel sheet, randomize them in a list, and then display the images contained within the rows, so that psychopy randomly takes an image from one column or the other. It is working offline, but it is not working online. If anyone can help me I would really appreciate it! Here is the python and javascript code:

Begin Experiment:

Python code

cue_list = [‘Image’, ‘blank’] * 31
shuffle(cue_list)

JS Code try #1
cue_list = ([“Image”, “blank”] * 31);
util.shuffle(cue_list);

Begin Routine:

Python code

if cue_list:
cue = cue_list.pop()
thisExp.addData(‘cue_type’, cue)
cue = eval(cue)

JS Code try #1
if (cue_list.length > 0) {
let cue = cue_list.pop();
psychoJS.experiment.addData(‘cue_type’, cue);
cue = eval(cue);
}

JS Code try #2
if (cue_list) {
cue = cue_list.pop();
psychoJS.experiment.addData(“cue_type”, cue);
cue = eval(cue);
}

Hello,

see the crib sheet by wakecarter how to modify your JS-part of the code. Auto-translated doesn’t work here. For example:

[0, 1] * 10

has to be translated (by hand) to

Array(10).fill([0,1]).flat();

Best wishes Jens

Thank you! I’ve gone through the crib sheet, and I have changed everything it suggested (code below) but am still stuck.

Begin Experiment:
cue_list = Array(31).fill([“Image”, “blank”]).flat;
util.shuffle(cue_list);

Begin Routine:
if (cue_list) {
cue = cue_list[0];
psychoJS.experiment.addData(“cue_type”, cue);
cue = window[cue];
}

Hello Bennett

you provide insufficient information.

Also, when posting code surround it with triple `to get properly formatted code.

Best wishes Jens

Try

if (cue_list) {
cue = cue_list.pop();
psychoJS.experiment.addData(“cue_type”, cue);
}

I assume that if(cue_list) is to prevent an error when the cue_list becomes empty.

What does cue = window[cue]; do? You had cue = eval(cue); before