Everything runs fine in the Builder. Things crash online with the error “ReferenceError: faces is not defined”. I believe it’s something to do with defining a variable in the “Begin Experiment” tab as opposed to the “Begin Routine.” I’m unsure what I should do.
var faces = ['Angry.png', 'Happy.png', 'Neutral.png', 'Jumbled.png'];
Followed by some transformation to duplicate it equivalent to *50 in Python (again, JS isn’t my best language so I’d need to look that one up). Was this generated by auto-translate or did you write it yourself manually? If it’s auto-translate we’ll need to change that in the program.
let faces = new Array(200);
for (i = 0; i < arr.length; i++){
faces[i] = 'Angry.png';
i++;
faces[i] = 'Happy.png';
i++;
faces[i] = 'Neutral.png';
i++;
faces[i] = 'Jumbled.png';
}
Notice, that this will not work if your array size is not a multiple of your file names. For instance, 199 or 201 will not work. Anyway this gives you 50-times angry aso. An alternative approach in which you don’t specify the array size is the following.
let faces1 = ['angry', 'happy', 'neutral', 'jumbled'];
let faces = ['angry', 'happy', 'neutral', 'jumbled'];
var i = 0
while(i < 49) {
faces = faces.concat(faces1);
i++;}
Notice that I initialize the array faces with some values. You have to keep this in mind for your counter. You don’t need this but then you have an array with no values.