ReferenceError: top_female_names is not defined

Description of the problem: The program runs fine in psychopy locally but when I upload to the server with my custom JS it fails to run telling me I have an uninitialised variable. I have tried debugging by commeting out code but the following still baulks. Any suggestions please. As you can see I have tried to strip the code back to its barebones.

if name { //(topbottom == “top”) && (gender == “F”) {
let name = “name”; //top_female_names[tfCount];
tfCount = (tfCount + 1);
}

Ok so I’ve made progress.

This code works:

if (topbottom == “top” && gender == “F”) {
name = “test”; // top_female_names[tfCount];
tfCount = (tfCount + 1);
}

but this doesn’t:

if (topbottom == “top” && gender == “F”) {
name = top_female_names[tfCount];
tfCount = (tfCount + 1);
}

I get the following error message -
Error

Unfortunately we encountered the following error:

  • ReferenceError: top_female_names is not defined

Try to run the experiment again. If the error persists, contact the experiment designer.

For clarity, I have the following code in my begin experiment tab:

top_female_names = [‘Olivia’, ‘Sophia’, ‘Ava’, ‘Amelia’, ‘Isla’, ‘Lily’, ‘Mia’, ‘Emily’, ‘Isabella’, ‘Freya’, ‘Aria’, ‘Ella’, ‘Evie’, ‘Grace’, ‘Ivy’, ‘Rosie’, ‘Sophie’, ‘Willow’, ‘Charlotte’, ‘Poppy’, ‘Elsie’, ‘Emilia’, ‘Sienna’, ‘Phoebe’, ‘Ruby’, ‘Hannah’, ‘Evelyn’, ‘Zara’, ‘Florence’, ‘Nora’];

Ignore all of this, have sorted the problem - for now…

1 Like

What was the issue?