I wanted to access the response (integer) to a slider component, store it in an array, and use the array in a later routine. I’ve tried a few methods in the JS code component, the console log either shows that the response is undefined or I would get an error.
Below is what I think I should do to access the slider response:
trialCounter = 0; rating = ; // name of the array storing the slider response
dat = NPOs.experimentHandler.psychoJS.experiment._trialsData; // "NPOs" is the name of the loop rating[trialCounter] = dat[trialCounter]['slider.response'];
trialCounter += 1; psychoJS.experiment.addData('thisTrialN', trialCounter);
This would give me an error:
TypeError: Cannot read property ‘slider.response’ of undefined
I guess there’s an issue accessing the trial index here so I’m not able to retrieve the slider response.
I’m new to JS, and would appreciate any help in troubleshooting this.