Trying to understand

Tell us what’s happening:
Hi, i don’t understand why my code isn’t working, i checked a lot of times but it doesn’t show anything.

Your code so far


function uniteUnique(arr) {
var newArr = [];

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

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/83.0.4103.61 Safari/537.36.

Challenge: Sorted Union

Link to the challenge:

it is an issue of arguments and parameters

your function has one single parameter, but three arguments are passed in
with arr you can access only the first argument (in this case [1, 3, 2])

you could use the rest parameter so that you can access all the arguments
with only that change it seems to work

thank you so much, i solved with this paramether (…arr) !!!