Why doesn't my solution work?

My code returns all the requested solution, but I can’t pass the test, where is the problem?

Thanks,


function destroyer(arr) {
// Remove all the values
console.log(arguments);
var args = Array.prototype.slice.call(arguments);
var arr0 = args[0];
var newArr = args.splice(1);

var selectArr = [];

for(let i = 0; i < arr0.length; i++) {
  if(newArr.indexOf(arr0[i]) == -1) {
    selectArr.push(arr0[i]);
  }
}
console.log(selectArr);

return arr;
}

destroyer(["tree", "hamburger", 53], "tree", 53);
// ["hamburger"]



Challenge: Seek and Destroy

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/seek-and-destroy

You’re returning your original variable “arr”, rather than the variable you intended, “selectArr”

1 Like