My code is throwing the following error:
cannot read property length of undefined in arr[i].length
function filterArray(arr, elem) {
let newArray = [];
for (let i = 0; i < arr.length; i++) {
for (let j = 0; j < arr[i].length; j++) {
if (arr[i][j] === elem) {
arr[i].splice(j, 1);
}
}
}
return arr;
}
console.log(filterArray([
[3, 2, 3],
[1, 6, 3],
[3, 13, 26],
[19, 3, 9]
], 3));