freeCodeCamp icon indicating copy to clipboard operation
freeCodeCamp copied to clipboard

Seek and Destroy Challenge not accepting correct output.

Open jle3 opened this issue 10 years ago • 2 comments

Challenge Seek and Destroy has an issue. User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36. Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

function destroyer(arr) {
  // Remove all the values
  function comp (element, index, array){
    return element !== this;
  }
  var result = arr;
  var arg = arguments;
  for(var i = 1; i<arg.length; i++){
    console.log(i);
    result = result.filter(comp, arg[i]);
  }
  return result;
}

destroyer(["tree", "hamburger", 53], "tree", 53);

im returning ["hamburger"] as requested in the last checkpoint but it's not being recognized? What am I missing?

jle3 avatar Feb 08 '16 03:02 jle3

I'm not exactly sure why the console is returning ["hamburger"], but if you type in console.log(this) in your comp() function, you'll notice that it logs either a String object or a Number object. One of those JavaScript quirks of assigning a value to this I guess. You'll have to convert those objects to their primitive values.

Please check out the Help Chat first if you're stuck on a challenge.

alistermada avatar Feb 08 '16 04:02 alistermada

Sorry, but Issues are not for code problems. As @alistermada say, please ask for help in Help Chat.

Thanks and Happy Coding!

SaintPeter avatar Feb 08 '16 23:02 SaintPeter