I want to solve this with filter instead of for loop i am not able to use filter need some help
function destroyer(arr, ...arg) {
let newarr=[];
var pro;
for(let j=0;j<arr.length;j++)
{
pro=false;
for(let i=0;i<arg.length;i++)
{
if(arr[j]!=arg[i])
{
pro=true;
}
else {pro=false;break;}
}
if(pro)
{
newarr.push(arr[j]);
}
}
return newarr;
}
console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/seek-and-destroy/