I think there are at least two problems with your code.
removeFromArr doesn’t work as intended: when you remove something from an array while iterating over it you will skip items.
Why? Let’s say you are in a for loop iterating over an array and your loop counter i is currently 2. Now you remove array[2], thus array[3] becomes the new array[2]. Then the loop continues and i is incremented. Now array[3] is checked, the value that is now in array[2] has been skipped.
That’s the reason why the case sym([1, 2, 5], [2, 3, 5], [3, 4, 5]) fails: sym([1, 2, 5], [2, 3, 5]) becomes [1, 3]. Then when you calculate sym([1, 3], [3, 4, 5]), you get the concatenated array [1, 3, 3, 4, 5]. You remove the first occurance of 3 while iterating over the array, effectively skipping the second 3 that comes next
That’s why you should never modify objects you iterate over, work with a copy instead.
You don’t handle the case where one array contains duplicates. The result should be a proper set meaning it should only contain unique values, i. e. [1, 2, 3] instead of [1, 1, 2, 3].
I wrapped your code in spoiler tags. It’s unlikely that anyone looking at this topic wouldn’t already have completed the task, but it’s good practice to blur challenge solutions anyways.
Yeah I finished the algorithm, all I did was modify the removeFromArray() helper function and filter the end result of the main function so there are no duplicates. Thanks again.