URL of experiment:
https://pavlovia.org/run/tzhu9/conjuntive-rb-category-learning/html/
Description of the problem:
I want to translate this Python code to JavaScript but received the
TypeError: Cannot read property ‘0’ of undefined error.
Python code
if not trials.thisN in [29, 59, 89, 119, 149, 179, 209, 239, 269, 299, 329, 359, 389, 419, 439, 469, 499]:
continueRoutine = False
my JS code
if (![29, 59, 89, 119, 149, 179, 209, 239, 269, 299, 329, 359, 389, 419, 439, 469, 499].includes(trials.thisN)) {
continueRoutine = false;
}
I tried to write my own JS code because the auto-generated code gave the same error, the auto code is
var _pj;
function _pj_snippets(container) {
function in_es6(left, right) {
if (((right instanceof Array) || ((typeof right) === "string"))) {
return (right.indexOf(left) > (- 1));
} else {
if (((right instanceof Map) || (right instanceof Set) || (right instanceof WeakMap) || (right instanceof WeakSet))) {
return right.has(left);
} else {
return (left in right);
}
}
}
container["in_es6"] = in_es6;
return container;
}
_pj = {};
_pj_snippets(_pj);
if ((! _pj.in_es6(trials.thisN, [29, 59, 89, 119, 149, 179, 209, 239, 269, 299, 329, 359, 389, 419, 439, 469, 499]))) {
continueRoutine = false;
}