Intermediate Algorithm Scripting - Seek and Destroy

why my code don’t show any changes in arr:
Describe your issue in detail here.

Your code so far

function destroyer(arr, ...arg) {
  for(let i=0;i<arg.length;i++){
   for(let j=0;j<arr.length;j++){if(j == arr.indexOf(arg)) {
   console.log(arr.splice(arr.indexOf(arg),1))
  }}
  }

   
  return arr;
}

console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));

Your browser information:

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

Challenge: Intermediate Algorithm Scripting - Seek and Destroy

Link to the challenge:

I think the instructions for this might be a little misleading. You don’t want to change the arr passed in to the function. You want to create a new array with only those values that aren’t passed into the function, and then return that new array.

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