| Reference | Downloads | Github

Array of objects as the condition file

Hi all,

I am trying to create unique pairs of stimuli for each participant. I created an array of objects as an example which basically is a unique pair of two elements from two different array.

const stimuli = [];

let Middle= [
   "gruts","hoons","awops","snains","chails", "spaves", "bunges","goples",


let Cat = [
  ["cars","Volvos","BMWs"], ["birds","parrots","sparrow"] , ["tools","hammers","saws"] , 
  ["reptiles","lizards","crocodiles"], ["trees","eucalyptus","willows"],
  ["dogs","labradors","spaniel"], ["furniture","desks","sofas"],
  ["weapons","swords","guns"], ["currencies","dollars","euros"],


// An example of one item
stimuli.push ({
  prem1: `All ${Cat[0][0]} are ${Middle[0]}`,
  prem2: `No ${Middle[0]} are ${Cat[1][1]}`,
  conc: `No ${Cat[0][0]} are ${Cat[1][1]}`

Now, my question is how to use this array as my condition file? I would appreciate any comments.

Hi @Omidrezaa, its easily done. Add this code to a “Begin Experiment” tab. Then, you need to remove the const from the stimuli declaration. Finally, add the stimuli variable as code to the loop e.g., $stimuli, in place of the filename.

1 Like