I am programming an online experiment using jspsych/javascript. The experiment consists of 100 blocks and after each block, the block_number gets updated by +1. There are two conditions. On 75 blocks, I want the program to show an image, and on 25 blocks, I want the program to show a letter. First, I generated 25 random numbers (that will serve as 25 block numbers), on which the letter should be shown. My problem is to tell the program to use these 25 numbers as block_number for the letter condition, but use the other block numbers as block_number for the image condition. Maybe I need to store the 25 numbers in a different format, that is, they are not stored as an array? Also in the if statement, how to "connect" block_number to these 25 numbers? Please see my code below. Thank you so much for your help, I really appreciate it!
// initialize block_number at the very beginning, it gets updated +1 after the for loop:
var block_number = 0;
// there are 100 blocks in total, and on 25 of them (picked randomly at the very beginning), a letter instead of an image should be shown:
var random_numbers = Array.from(Array(95), (x, index) => index + 5);
random_numbers = jsPsych.randomization.shuffle(random_numbers);
var block_keys = random_numbers.filter((random_numbers,idx) => idx < 25);
block_keys.sort();
// in the if statement, I want to show letters only when block_number is equal to block_keys, otherwise, images should be shown:
if (block_number == block_keys) {
show letter
} else {
show image
}