@orionkwilson I just completed this challenge with
.filter() which takes an optional parameter and a
for loop that iterates through the arguments passed into
destroyer() in Seek and Destroy.
It took quite a bit of researching the MDN
.filter() page and Google searches which mostly returned Stackoverflow questions but it worked out in the end.
The example code in MDN,
var new_array = arr.filter(callback[, thisArg]) was a little confusing to me. I found out that anything between square brackets (
) is optional but it didn’t show what code with the optional parameter should look like . It would have been nice it such an example had been shown.
My first idea was to call the function inside the for loop but I got a message saying I shouldn’t do that.
return element != argument[i];
Next, I tried declaring the function outside of the for loop but I couldn’t find a way to reference the arguments passed into
destroyer(). Then I bumped into this thread on Stackoverflow in which the OP is actually looking for a solution to Seek and Destroy.
This lead me to using
this in the function to compare the element to a variable. This worked. The OP says second example didn’t work. Not sure why, it could be because he used strict comparison (
!==) instead of loose comparison (
Hope that helps.