Check if a survey-text response matches an element in an array and define different outcomes #2233
-
Hello! I am planning to run a two-part experiment on Prolific. In the first part, participants will be randomly allocated to one of the two groups - Square or Triangle. This means that for the second part of the experiment (happening ~7 days later), I will know which Prolific IDs have been assigned to which group membership in advance. I am currently coding the second part of the experiment and I am trying to see which group has each participant been assigned to in part one by comparing the Prolific ID they type in to Prolific IDs I have in the two arrays (prolificIDsSquare, prolificIDsTriangle). Depending on the outcome of this comparison, I want to change the value of currentGroupMembership to reflect their group membership from part one. If the Prolific ID does not match any element from two pre-defined arrays, I want participants to see an alert and repeat the survey-text element (to basically double-check whether they entered the Prolific ID correctly).
Currently, the if-else statement always goes to 'else' and shows the alert box. Does anyone have an idea how to access what the participants have typed and compare that to the two arrays? Thank you in advance! Note: In the final version of the experiment, I will probably not rely on what participants have typed, but scrape their Prolific IDs directly, but the questions about accessing their responses and comparing them to an external value (or values) still bug me. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi @jelkastojanov, My approach to debugging this would be to put a breakpoint in the In case you aren't familiar with adding a breakpoint, here's a short overview. |
Beta Was this translation helpful? Give feedback.
-
In case anyone ever needs a similar solution, the code below worked (just specify the right timeline in jsPsych.init at the very end):
|
Beta Was this translation helpful? Give feedback.
In case anyone ever needs a similar solution, the code below worked (just specify the right timeline in jsPsych.init at the very end):