Hi guys,
so after more than a day of struggling, I finally managed to pass this challenge.
I was wondering tho , if I use this code:
if(arr.indexOf(agts[j])!==-1),
the code wont work, it will still initiate “splice” with starting point of “-1”, I dont understand why.
Thank you
V
Your code so far
function destroyer(arr) {
var agts= Array.prototype.slice.call(arguments,1);
for(var i=0;i<arr.length;i++){
for(var j=0;j<agts.length;j++){
if(arr.indexOf(agts[j])>-1)
arr.splice((arr.indexOf(agts[j])),1);
}
}
return arr;
}
destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36
.
Link to the challenge: