While you can code in jsPsych, it’s much easier to add code components to Builder experiments.
For example, have a look at my Independent Randomisation demo