Sorted Union - Code works (I think?) But will not pass tests

Sorted Union - Code works (I think?) But will not pass tests
0

#1

Hello, I believe I have written some code that while not elegant does pass all of the test cases for Sorted Union. However, when I submit the code I do not see that any of the test cases have registered as a pass. Could someone explain to me a) why this is the case or b) why my code is defective? Please see below and thank you in advance!

function uniteUnique(arr) {
  var arr = [];
  var unique = [];
  
  for (var i = 0; i < arguments.length; i++){
    arr.push(arguments[i]);
  }
  

  for (var i = 0; i < arr.length; i++){
    for (var j = 0; j < arr[i].length; j++){
      if (unique.indexOf(arr[i][j]) === -1){
        unique.push(arr[i][j]);
      }
    }
  }
  
  return unique;
  
  
}

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

#2

Try with a New Windows Incognito in Chrome.


#3

When I pasted your code in FCC editor I go two warnings (yellow triangles). Correct them.


#4

Thanks jenovs,

It seems like it did not like my reassignment of arr on line 2.