New course! Every coder should learn Generative AI!
Try a free lesson+ 1
Basically, what that does is check if elem is in the array at index i of arr.
arr[i] gets the ith element in arr.
In this case, arr is a 2D array, so you are getting another array.
The indexOf(E) method gets the index of the given parameter E, if it is not in the array, it returns -1 because -1 is an invalid index for an array.