Sorted Union; removing duplicates

Tests show that I was able to unite the arguments into an array, but not able to remove the duplicates. I have used a similar set up with filter for removing duplicates on a previous challenge, but I having a hard time this time around. I would appreciate any help with this. Thanks for your time.

function uniteUnique(...args) {
  var bank = [];
  for (let arr in args) {
  return bank.filter((item, pos) => (bank.indexOf(item) == pos));

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

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.


Your filter is fine, but take a look at

  1. Why you are using , which is more suitable for objects
  2. how you are concatenating the array