# Https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sorted-union

I’m trying to condense the arrays into one singular array. Next I extract the values from the array omitting any repeats. However when using the set object I’m left with the error (ReferenceError: set is not defined). Any help would be greatly appreciated.

``````  **Your code so far**
``````
``````function uniteUnique(arr) {
const singularity = arr.flat(Infinity);
for(let i = 0; i < singularity.length; i++){
new set(singularity);
}

}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
``````
``````  **Your browser information:**
``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36`

Challenge: Sorted Union

Hey there and welcome to the forums!

Per JS standards the `S` would be capitalized as it’s a constructor. Checking the documentation we can see that is the case:

function uniteUnique(arr) {
const singularity = arr.flat(Infinity);
for(let i = 0; i < singularity.length; i++){
return […new set(singularity)];
}

}
// made a slight alteration but still no luck

It doesn’t look like you’ve changed your call to `set()`. As the lesson says `set()` is undefined.

However:

1 Like

What do you think this line does?

returns a single array of all the number transforming[1, 3, 2], [5, 2, 1, 4], [2, 1] …
Into [1,3,2,5,2,1,4,2,1] ?

How? You never use any of the function arguments.

1 Like

function uniteUnique(…arr) {
const singularity = […arr.flat(Infinity)];
return […new Set(singularity)];

}
//thank you I see I only took in one of the parameters. This way singularity is an array and goes though all the arguments

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.