The objective is to iterate through the outer loop and then through the inner loop. After that we need to filter the parameter which is passed as 'elem'. The new Array (newArr) should return an array without the 'elem' element.
function filteredArray(arr, elem) {
let newArr = [];
for(var i = 0; i<= arr.length; i ++){
for(var j = 0; j<=arr[i].length ; j++){
if(arr.indexOf(elem)!= -1){
newArr.push(arr[i]);
}
}
}
return newArr;
}
console.log(filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3));
What is wrong with this logic ?