I am wrong about this problem?

I am wrong about this problem?


I was requested to rite a function that takes two or more arrays and returns a new array of unique values in the order of the original provided arrays. In other words, all values present from all arrays should be included in their original order, but with no duplicates in the final array. The unique numbers should be sorted by their original order, but the final array should not be sorted in numerical order.

The problem es that the function call have three arguments and function only receives one. My question is;

Is the function header right?

If is right how I could do to get all the info because actually on can access the first array. Here the code:

function uniteUnique(arr) {
  var newArr=[];
  var args = Array.from(arr);
  return newArr;

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


You could technically not define any function parameters for uniteUnique. You will need to take advantage of the arguments object in JavaScript to access one, two, three,…many extra values passed into the function. When you specifically define a parameter (like arr) in the above, then it represents the first value passed into the function.


Thanks. I understand that, but ther’s no problem if I take out the argument of uniteUnique()?


The arr parameter is just a placeholder that you could use. You can leave it out all together and just use the arguments object. See below for an example of working with the arguments object.

function myFunction() {
  var args = Array.from(arguments); // now args is an array
  for (var i in args) {

The above function call produces:



Thanks for your help I am on the way to resolve the problem. Again thanks a lot.