Corsi Backward span

I’ve found multiple corsi forward span tasks and have been working on making a corsi backward span task; however, I’m a bit lost. The script I currently have does exactly what I want it to do, except for reading the answers as correct in the reverse order that they were presented. For example, if the sequence is: 1,2,3 the correct answer would be 3,2,1. Would anyone have any suggestions on how to do this? Any help is much appreciated.

@Christine93, you will want to compare the sequence of the stimuli with the sequence given by the participant, but with the stim sequence reversed. However, it will be best to do this without changing the order of the original sequence. In Python, you could do the following, where correct will be true or false, depending on whether the answer is correct or incorrect:

correct = (stimSequence[::-1] == responseSequence[::-1])
thisExp.addData("correctSequence", correct)  # save response

In JavaScript, you could use:

arrayEquals = function(a, b) {
  return Array.isArray(a) &&
    Array.isArray(b) &&
    a.length === b.length &&
    a.every((val, index) => val === b[index]);

revStimSequence = [].concat(stimSequence).reverse()
correct = arrayEquals (revStimSequence, responseSequence)
psychoJS.experiment.addData("correctSequence", correct)  // # save response

Thank you!