If .slice() is a problem, could you try the .concat command instead? e.g. for this line:
stim_unbiased_la = all_la_stim.slice(0, 3);
try:
stim_unbiased_la =stim_unbiased_la.concat(all_la_stim[0], all_la_stim[1], all_la_stim[2]);
Also, I am not sure you are using the util.shuffle command correctly. As far as I understand, that should be at the beginning of the experiment in an only JS code and then you can use shuffle
in the JS code. See this related post:
Hope that helps!