Please I want know if this is concise and clear enough as it passed the challenge

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

function destroyer(arr) {
let agr = [...arguments];
let newArr = agr[0];
let newArr1 = [];
  for(let i =0; i < newArr.length; i++){
        if(agr.includes(newArr[i]) === false){
  return newArr1;


console.log(destroyer(["tree", "hamburger", 53],  "tree", 53 ));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36

Challenge: Seek and Destroy

Link to the challenge:

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

Learning to describe problems is an important part of learning how to code.

Also, the more information you give us, the more likely we are to be able to help.

1 Like

I agree with Jeremy, but was already typing when he responded…

Going off your title and inferring what you mean: Is it concise enough, is it clear enough?

Well what does that mean? What is the goal?

Could it be more concise? Sure, this could be solved in one line:

const destroyer = (arr, ...keysToRemove) => arr.filter(el => !keysToRemove.includes(el))

Does that make it better? I would say that we have to be careful about being “too concise” at the expense of clarity. I could make it even smaller, like this:

const destroyer = (a, ...r) => a.filter(x => !r.includes(x))

Is that better? It’s more concise. But it’s also less clear. It’s all about a balance, trying to maximize both. And to me clarity is much more important than concision.

Your solution? For a learner, it’s great! You solved the problem. You found a solution. It works. You reinforced your coding knowledge. You understand what is happening on an algorithmic level. That is the purpose here - you nailed it.

If it came across my desk in a PR review, I might critique it for creating unnecessary variables, instead of leveraging some functional programming and ES6 features.

In “the real world” I would expect to see something like my first example. It is clear and concise. It is easy to understand (if you understand ES6 and FP, which a professional coder should) and is (imho) easier (or at least quicker) to absorb than the lengthier example you created. This is where concise is good - all things being equal, fewer lines are easier to digest and to maintain. There are fewer opportunities for bugs. The second example I provided? That is just being concise to try to show off. I would not like the second example.

So in summary, good job. You solved the problem. When I was at your stage, my solution was probably very similar. Is it the “best” solution? Maybe not. But it’s excellent for where you are.

I do have one complaint in your code:

let agr = [...arguments];

Why make a copy? You don’t need to mutate it in anyway so there is no need.

if(agr.includes(newArr[i]) === false){

Most people would write something like:


Unless you are explicitly checking for false, then a falsy check is sufficient.


This bothers me a little, since agr contains as it’s first element a reference to newArr. It works for this test data. But I wonder if it would fail for some array with a circular reference.

const arr = ["tree", "hamburger", 53];

// ["tree", "hamburger", 53, Array(4)]

console.log(destroyer(arr, "tree", 53));
// ["hamburger"]

In other words, the original array is something that we’re checking to remove from the original array. That’s kind of an edge case, and maybe it is desirable behavior - it just struck me as odd. If I saw that come across my desk I would ask questions.

But still, good job.


let arg = […arguments];
The reason for this is so as to turn the whole arguments into an array, then I extracted the first index element let newArr = arg[0];
Thanks for this !arg.includes(newArr[i]), I will improve over time and also work on applying functional programing for solving the challenges to come. Thanks alot for comments and words of encouragement.

OK, I misread the code a little. But OK, arguments is already an array, right? Furthermore (and maybe it is beyond the scope of what you’ve learned up to this challenge, I don’t know… But you could just grab them with a rest operator:

function destroyer(...arr) {

Or, you could do something like I suggested that would break off the first parameter and “rest” the rest into their own array.

Whatever. It’s all about learning. Have fun on the next one.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.