Thanks a lot for your response.
This code is really helpful but, if I understand it correctly, it always chooses ‘hello’ and ‘world’ for the first two trials (i.e. first block) and then ‘eyb’ and ‘etam’ for the third and fourth trial (i.e. second block). The order of the trials within each block varies from participant to participant, which is what I want.
However, I would also like to vary the words in the first block across participants. For example, Participant A sees ‘hello’ and ‘world’ in the first block (and ‘eyb’ and ‘etam’ in the second block). Participant B sees ‘hello’ and ‘mate’ in the first block. Participant C sees ‘world’ and ‘bye’ in the first block, etc.
Could you help with that?
I was also wondering what the order array does exactly. I started my PhD just a year ago and I am not very familiar with coding but trying my best to learn it at the moment. I tried to look up the individual elements: From what I found, the first part creates an array with four undefined slots. These are then mapped with the .map function and sorted with the .sort function. What I can’t follow are the lambda (?) functions inside .map and .sort. From playing with the code, the .map and .sort functions seem to make sure that not only rightLeft words are displayed but I can’t work out why that is.
I appreciate if you can’t explain this in detail. Can you recommend any books or websites that I could have a look at to learn this type of coding?