'Begin Experiment' code not working – Online Builder with Code components

Probably a scope issue. Remove the word “var” from before each variable so they will be declared as implicit globals See here: Variable not defined