# Suggested Rewrite for Sorted Union

IMO the description of the challenge and the expected result don’t match. Here’s the current text:

Write a function that takes two or more arrays and returns a new array of unique values in the order of the original provided arrays.
In other words, all values present from all arrays should be included in their original order, but with no duplicates in the final array.
The unique numbers should be sorted by their original order, but the final array should not be sorted in numerical order.
Check the assertion tests for examples.

This reads as though uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]) should return [3, 5, 4], i.e. “unique values,” “no duplicates.”

However, the expected output is [1, 3, 2, 5, 4].

Here’s my suggestion:

Write a function that takes two or more arrays and returns a new array consisting of the values from the first array followed by the values from the remaining arrays that are not found in the first array.
All values in the returned array should appear in the order in which they were provided. Do not sort in numerical order.
Example: uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]) should return [1, 3, 2, 5, 4].

[Should be raised as an issue on the FCC Github repo, but] yeah, I thought that was quite a confusing wording as well, though why not just:

Write a function that takes two or more arrays, merges them together, and returns a new array with all duplicate values removed. The values in the returned array should appear in the order they were provided.

Then:

Example:

``````uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1])
``````

In this case, the second and third `1`s and `2`s that appear are {ignored|removed|excised|whatever}, and the return value will be:

``````[1, 3, 2, 5, 4]
``````

And maybe mention sets, given that this is what this is (or link to JS’ `Set`? I dunno).

1 Like