Seek and Destroy - doubt

Hallo: my algorithm is returning [1, 1] but not, for example, [1, 5, 1]. Shouldn’t it also work since in the for loop I’m working with the length of arr2?

function destroyer(arr, ...arr2) {
  let x = []
  for(let i = arr2.length; i > 0 ; i--) {
    x.push(arr.find(element => element !== arr2));
  };
  console.log(x)
  return x;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

Thanks!!

What does arr.find() return?

1 Like

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