TypeError: Converting circular structure to JSON when using util.index

URL of experiment:

Description of the problem:
I am trying to set up a ‘select all that apply’ kind of trial, with an exclusive ‘none of the above’ option as well as an editable ‘other’ text box. The polygon and text should change colors when clicked and store value; change colors again and remove the stored value when clicked again.
It works well locally on Builder/using python code, but I am having trouble converting it to JS. I get the following error:

image

I think it might have to do with finding/adding/removing the polygons and textstim values from the list that stores the selected values, but I can’t figure out what is wrong. Any help would be greatly appreciated!

Oops I fixed this issue by using .indexOf() instead of utils.index.