Tell us what’s happening:
Hello I think my code work just fine and is returning the right array, I do not know why the exercise will not accept my code. what might be the caused of the problem?
Your code so far
function filteredArray(arr, elem) {
let newArr = [];
// Only change code below this line
let arrayCopy = arr.slice(0, arr.length);
for (let i = 0; i < arrayCopy.length; i ++){
for(let j = 0; j < arrayCopy[i].length; j++){
if(elem === arrayCopy[i][j]){
arr.splice(arr.indexOf(arrayCopy[i]), 1);
break;
};
};
};
newArr.push(arr);
// Only change code above this line
return newArr;
}
console.log(filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36
Challenge: Basic Data Structures - Iterate Through All an Array’s Items Using For Loops
Link to the challenge: