indexOf error ! Seek and Destroy

Seek and Destroy

TypeError: arrx.indexOf is not a function

function destroyer(arr) {
  var arrx = arr[0];
  for(var i=1;i<arr.length;i++){
  while(arrx.indexOf(arr[i]) != -1){
    arrx.splice(arrx.indexOf(arr[i]),1);
    }
  }
  return arrx;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

If arrx is not an array, then it does not have the method .indexOf().

1 Like

Take a look at your console.log here. arr is the array passed into the function, not the full arguments list. Like the instructions say, you’ll need to use the arguments object to access everything. :slight_smile:

2 Likes