Seek and Destroy didn't understood the solution

Seek and Destroy didn't understood the solution
0

#1

I didn’t actually understood the arr here…what actually it does …this is working code…but I didn’t understood how it has used arr as a array and used the comparison operator

function destroyer(arr) {
var args = Array.prototype.slice.call(arguments);

for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < args.length; j++) {
if (arr[i] === args[j]) {
delete arr[i];
}
}
}
return arr.filter(Boolean);
}```
Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/604.4.7 (KHTML, like Gecko) Version/11.0.2 Safari/604.4.7.

Link to the challenge:


#2

This is a needlessly complicated (and honestly problematic) solution. Here is a similar discussion.

I highly recommend resetting this challenge and working on a solution that you do understand. Feel free to reach out to fellow campers if you get stuck. You’ll learn and accomplish much more if you get help working forward on your own solution than trying to understand someone else’s. The experience of breaking down a problem and building your way to a solution is at least as important to learn as the language itself. (I would argue more important.)


#3

I tried a lot on this problem…but I didnt understood the role of arr…can u just help me in dat?


#4

arr is the array that was passed in as an argument.


#5

yeah but while defining the function(destructor) we are declaring only one argument…but while calling how can we pass more than one argument,I mean other than array…please have a look at the code…or is it possible?


#6

You can pass as many arguments as you want to a function. The function only defined one parameter (arr), so only the first argument passed will be assigned to arr. To access the others, you must make use of the arguments object, which this solution does.


#7

thank a lot…now I understood:relaxed: