Custom button on list view

Custom button on list view

I want to add a custom button on a list view that runs a custom function.
In the custom function I'm mapping the ID as the argument. I assume all the ids of the selected records get passed as some sort of array?
How do I iterate the array to perform the function on each selected record?

My function/button currently works if I select just one record but not if I select multiple records.

(How can I easily see exactly what gets passed to the function?)

I found this forum question which suggests id of the selected records will go as one param with "|||" as separator but doesn't say how to separate them https://help.zoho.com/portal/en/community/topic/custom-button-in-list-view-how-to-get-selected-rows-in-custom-function