Python to javascript error

URL of experiment: impasseandcuriosity [PsychoPy]

Description of the problem: Error checking python code has not converted correctly to javascript.

The Python code:

user_answer = answer_text.text.lower().strip() # Convert to lowercase and remove extra spaces
correct_answer = correct.lower().strip() # Convert correct answer from conditions file to lowercase

Store if it was correct

is_correct = (user_answer == correct_answer)
thisExp.addData(‘user_answer’, user_answer)
thisExp.addData(‘is_correct’, is_correct)

The automatically converted JavaScript code:

user_answer = answer_text.text.toLowerCase().strip();
correct_answer = correct.toLowerCase().strip();
is_correct = (user_answer === correct_answer);
psychoJS.experiment.addData(“user_answer”, user_answer);
psychoJS.experiment.addData(“is_correct”, is_correct);

Can anyone talk me through the changes I would have to make for it to work online?

Merry Christmas!!

I haven’t used .strip() so I imagine that doesn’t work. I think it might need to be manually changed to .trim()

Personally I’ve been using .replace(' ','') but I might look at .trim() in future.

Yes - you’re right. It needed to be

user_answer = answer_text.text.toLowerCase().trim();

etc., and that worked!

Thank you!!