Having probelm doing 'sorted Union' on intermediate challenge. HElp!

Having probelm doing 'sorted Union' on intermediate challenge. HElp!
0

#1

I 'm doing the ‘sorted union’ on intermediate algorithm and having problem using the reduce()…
Below is the code I wrote.

function uniteUnique(arr) {
var newArr = arr.reduce(function(a,b){
    var i;
    for(i=0;i<b.length;i++){
     if(a.indexOf(b[i]) == -1)
      a.push(b[i]);      
      }
    return a;
    });
  return newArr;  
}

#2

The uniteUnique function is expected to receive more that one array as input. Your code only touches the first one (because arr holds a reference to that first array, but the rest are not referenced).

You can rewrite the function uniteUnique(arr) as function uniteUnique(...arr) so all of the inputs are gathered in the arr variable.


#3

oh. I thought there was something wrong with the way I use reduce().
thank you. I see now.