Removes the first matching element from the given array or adds it if the array doesn't contain the element yet.
the original element if removed, undefined if added
filterDuplicateElements to make sure an array contains unique values
Removes the first matching element from the given array or adds it if the array doesn't contain the element yet.