[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