psychopy.org | Reference | Downloads | Github

How to code response message in javascript

How do I write javascript version code for this block?

if not key_respTrain.rt:
train_msg = ‘Failed to respond’
elif key_respTrain.corr==corrAns:
train_msg = ‘Correct!’
else:
train_msg = ‘Wrong!’

@CatK, try the following:

if (key_respTrain.rt === undefined) {
    train_msg = 'Failed to respond';
} else if (key_respTrain.corr === corrAns) {
    train_msg = 'Correct!';
} else {
    train_msg = 'Wrong!';
}