Referenceerror is not defined for array initialized in BeginExperiment

URL of experiment: Sign in · GitLab

Description of the problem: I’ve tried defining an empty array in a BeginExperiment component several different ways, and assigning values to it multiple different ways, but I always get the ReferenceError: points_append in not defined error. I can get it to work in the console by running it in the different ways noted below, but not while running the experiment through pavlovia. I could really use some help with this.

In my experiment js file linked above the array is initialized in line 331-332, and the value is assigned in line 5168.

Here are the different ways I’ve tried initializing the array

var points_append;
var points_append = new Array()
let points_append = new Array(6) # 6 is the max size of the array
let points_append = new Array()

and assigning the values in a code component at the end of a block loop:

points_append[BlockNum]=points_cumul;
points_append.push(points_cumul);

I was able to fix this issue. On the begin experiment code tab i had to init the array as points_append=[];. This added var points_append to the beginning of the js script. I’m still not sure why my code didn’t work when it works in the console.