function destroyer(arr){
let len = arguments.length;
let arry = [];
let mainArr = arguments[0];
for(let i = 1;i< len;i++){
arry.push(arguments[i])
}
console.log(mainArr);
for(let x =0;x<mainArr.length+1;x++){
for(let j=0;j<arry.length;j++){
if(mainArr[x] === arry[j]){
mainArr.splice(mainArr.indexOf(arry[x]),1);
}
}
}
console.log(mainArr);
};
so this function an array followed by extra some arguments. I need to remove element of this array which is same as those extra argument. So, I create this function but the result I get is
[1,2]
Please anyone tell me why last 2 isn’t remove?