URL of experiment: https://pavlovia.org/run/laurapissani/typing_demo/html/
Description of the problem: I am trying to TYPE, use shift and delete in JS (to run online), the code bellow works for PY but not JS (the autotranslator is not fully working for this line of code). Any chance someone can help me correct my code and add the shift to capitalize in JS:
Ps. I have read multiple post on how to write in JS, but I still can’t fine how to delete and capitalize.
This is the PY:
L=Answer.keys
nb_back=L.count("backspace")
for i in range(nb_back):
pos=L.index("backspace")
if pos>0:
L.pop(pos-1)
L.pop(pos-1)
nb_space=L.count("space")
for i in range(nb_space):
pos=L.index("space")
L[pos]=' '
Refined_response=''.join(L)
This is the autotranslated JS (does not work):
L = Answer.keys;
nb_back = L.count("backspace");
for (var i = 0, _pj_a = nb_back; (i < _pj_a); i += 1) {
pos = L.index("backspace");
if ((pos > 0)) {
L.pop((pos - 1));
L.pop((pos - 1));
}
}
nb_space = L.count("space");
for (var i = 0, _pj_a = nb_space; (i < _pj_a); i += 1) {
pos = L.index("space");
L[pos] = " ";
}
Refined_response = "".join(L);
Gives me this error:
TypeError: Cannot read property ‘count’ of undefined