psychopy.org | Reference | Downloads | Github

Translating Python into Javascript

Hello,

this code has been working fine with Python, but whenever I enter condition numbers at the beginning of a trial, it automatically follows a 0,1,2,3…sequence instead of the one I asked for.
I assume it’s because I didn’t translate the code properly.
Anyone who can help me with that?

Python:

if expInfo['condition'] == '1':
    actual_rows = [0,1,2,3,4,5,6,7]
if expInfo['condition'] == '2':
    actual_rows = [0,1,2,3,6,7,4,5]
if expInfo['condition'] == '3':
    actual_rows = [0,1,4,5,2,3,6,7]
if expInfo['condition'] == '4':
    actual_rows = [0,1,4,5,6,7,2,3]
if expInfo['condition'] == '5':
    actual_rows = [0,1,6,7,2,3,4,5]
if expInfo['condition'] == '6':
    actual_rows = [0,1,6,7,4,5,2,3]
if expInfo['condition'] == '7':
    actual_rows = [6,7,0,1,4,5,2,3]

JS

if(expInfo['condition'] == '1'){
    actual_rows = [0,1,2,3,4,5,6,7]};
if (expInfo['condition'] == '2'){
    actual_rows = [0,1,2,3,6,7,4,5]};
if (expInfo['condition'] == '3'){
    actual_rows = [0,1,4,5,2,3,6,7]};
if (expInfo['condition'] == '4'){
    actual_rows = [0,1,4,5,6,7,2,3]};
if (expInfo['condition'] == '5'){
    actual_rows = [0,1,6,7,2,3,4,5]};
if (expInfo['condition'] == '6'){
    actual_rows = [0,1,6,7,4,5,2,3]};
if (expInfo['condition'] == '7'){
    actual_rows = [6,7,0,1,4,5,2,3]};

Thank you in advance!

Hi @rebecca.shane, would you mind sharing the URL for your task so I can assist with debugging?

The problem was solved by deleting the ‘[…]’ brackets and only using ‘1,2,3…’.
Thank you anyways!