Why can I not do the Seek and Destroy challenge using the below code? It seems that the function compare is returning only 1 value even if there’s a loop. The code below returns an array [1,3,1,3] instead of [1,1]. Please help!
Your code so far
function destroyer(arr) {
// Remove all the values
var i;
var arr2=[];
var arr1 = arr.slice.call(arguments[0]);
for(i=1; i<arguments.length; i++){
arr2.push(arguments[i]);
}
return arr1.filter(compare);
function compare(value){
for (i=0; i<arr2.length; i++){
return value != arr2[i];
}
}
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/seek-and-destroy