I can't figure out why this is not working. I know the issue comes from the 8th line in the condition if(arr[i][j]===elem).
function filteredArray(arr, elem) {
let newArr = [];
for (let i = 0; i < arr.length; i++) {
for(let j = 0; j < arr[i].length; j++) {
if(arr[i][j]===elem) {
newArr.push(arr.splice(i,1));
}
}
}
return newArr;
}
if I enter in my console a test like :
console.log(filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3));
I get the error arr[i] is undefined.