Transforming Results To Eliminate Duplicates

I have a query that returns duplicate records because of how the query has been setup. In Default Value of textInputEmail component I want to write a JavaScript that converts the data results array that is assigned to textInputEmail.value and split the duplicate emails at "," so that I can assign the results to a Set to eliminate duplicates in the received "client_email" field.

I am new, to ReTool and JavaScript, this is obviously not working, how else can I do this?

Are the returned records exact duplicates? If so, did you try to update the query using SELECT DISTINCT (or correct the joins if that is what is causing it) to get a distinct set of data?

You can use JS for this if absolutely necessary, but it would probably be best to correct the query in the first place.