# Intermediate Algorithm Scripting - Sorted Union

Tell us what’s happening:
Describe your issue in detail here.

function uniteUnique() {
return […arguments]
.flat()
.filter((item, ind, arr) => arr.indexOf(item) === ind);
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
Can Someone please explain this line of code? " .filter((item, ind, arr) => arr.indexOf(item) === find);" how it is actually working? I can’t understand. Please help.

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

Challenge: Intermediate Algorithm Scripting - Sorted Union

Hello there.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more information you give us, the more likely we are to be able to help.

1 Like

Thank you for your guidance. So when the filter method is used, there are three variables “item”, “ind” and “arr” inside the parenthesis. I want to figure out what “arr” actually represents . “ind” means the index of the current element being passed. But how are duplicate values omitted when the filter method is used on the […arguments] ?

Please look at the line below for the given solution as mentioned above.

.filter((item, ind, arr) => arr.indexOf(item) === ind);

I want to know how this line of code is working actually.

1 Like

Look at the original code given by the exercise. You should be able to spot what arr is….

1 Like

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