Description of the problem:
I am trying to conduct an experiment about making predictions about facts, where participants get the option to indicate when they think the ‘fact’ is not true. To do this, I have written Python code to display a white box that turns black when clicked. However, when auto converting this to JavaScript in order to run the experiment online, the white box does not turn black anymore. Here is the JavaScript code:
Begin routine, I expect that this works:
Checkboxes = [Implausible];
Clicked = [];
for (var box, _pj_c = 0, _pj_a = Checkboxes, _pj_b = _pj_a.length; (_pj_c < _pj_b); _pj_c += 1) {
box = _pj_a[_pj_c];
box.color = "white";
}
Each frame:
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);
for (var box, _pj_c = 0, _pj_a = Checkboxes, _pj_b = _pj_a.length; (_pj_c < _pj_b); _pj_c += 1) {
box = _pj_a[_pj_c];
if ((mouse.isPressedIn(box) && (! _pj.in_es6(box.name, Clicked)))) {
box.color = "black";
Clicked.push(box.name);
}
}
Does anyone have a clue what could be going wrong here? I haven’t worked with JavaScript before and I can’t find out what’s going wrong. Thanks so much in advance!