Iterate Through All an Array's Items Using For Loops-

I have spent so long trying to figure out what is wrong with this code and it’s driving me bananas.

Link: https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-data-structures/iterate-through-all-an-arrays-items-using-for-loops

function filteredArray(arr, elem) {
  let newArr = [];

  for(var i=0; i<arr.length; i++){
    if(arr[i].indexOf(elem) !== -1){ 
      arr.splice(arr[i],1);  
      i--;
    }    
    
  }
newArr =[...arr];
  return newArr;
}
// change code here to test different cases:
console.log(filteredArray([[1, 2, 7], [1, 3, 2], [2, 3, 26], [19, 2, 9]], 3));

[edit]
I misread your function the first time, apologises.

The error comes from the way you splice.
splice start and deleteCount should be indexes, so far you are passing the content of the array

arr.splice(arr[i],1);

Maybe you meant

arr.splice(i,1);

edit: I personally don’t like the use of splice on the element you are looping on; since splice changes the content of the given array, you may loose the “integrity” of your array since it may changes its content mid-execution

Thank you so much! I really appreciate it.