function filteredArray(arr, elem) { let newArr = [];
Iterating through each element of the multidimensional array.
for (let i=0;i<arr.length;i++){
for (let j=0;j<arr[i].length;j++){
If the value matches the argument passed, assign variable x to the current iteration's nested array value
if (arr[i][j]==elem){
let x = indexOf(arr[i][j]);
Remove the element with the index equal to variable x.
arr[i][j].splice(x,1);
Add the remaining elements of the nested array to the new array and return it.
newArr[i].push(...arr[i][j]);
}
}
}
console.log(newArr);
return newArr;
}
HOWEVER THERE IS AN ERROR THAT SAYS 'indexOf is not defined'
I don't understand why it doesn't work. It returns undefined for indexOf in every iteration. Please review my code and share your thoughts.