I don't see bugs, but already it has one! (the code doesn't work)

I don't see bugs, but already it has one! (the code doesn't work)
0.0 0

#1

Tell us what’s happening:

Your code so far

  // Creates an empty array to store our final result.
  var arrayOfUniqueValues = arr1;
  
  for(var i=0; i < arguments.length; i++){
    for(var j=0; j < arguments[i].length; j++){
      
      if(arrayOfUniqueValues.indexOf(arguments[i][j]) === -1){
        arrayOfUniqueValues.push(arguments[i][j]);
      }
    }
  }
  
  return arrayOfUniqueValues;
}

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

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36.

Link to the challenge:


#2

You tried to assign arr1 to arrayOfUniqueValues, yet arr1 does not exist anywhere in your code.

var arrayOfUniqueValues = arr1;

To create an empty array you can use

var arrayOfUniqueValues = [];

#3

Your function is malformed. Functions must have the following syntax:

function funcName() {
}
//or
var funcName = function() {
}
//or
const funcName = () => {
}
//...etc.