Iterate Through All an Array's Items Using For Loops -- problems data not showed using console/write after filtered

My Problem
I was trying to output the array which dont have the number from the elem arguments. I think there is no problem with my code even the challenges is passed, but when i tried to console/write it, it doesn’t showed up. is there anything i have been missing?

function filteredArray(arr, elem) {
  let newArr = [];
  // change code below this line
  for(let i = 0; i < arr.length; i++){
    if(arr[i].indexOf(elem) < 0){
  // change code above this line
  return newArr;

// change code here to test different cases:
console.log(filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3));

no its all good it will show in the browser console if you inspect it

sadly, it doesn’t show up, it returns zero data as shown below:


So, is there anything wrong with my code?

did you run the code?

yes, I use chrome, and that image is the result

you should console.log the array

  return newArr;

hey, sorry for the problems, you are right there were no problem with my code, it was just me whose missing off with the array that i want to push.
I give the array as shown below:

console.log(filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3));

my code was to push an array which don’t have number 3 inside it, and sadly, i didn’t notice that every of my array has number 3 :sweat_smile:, sorry for any trouble i cause.

1 Like

no trouble mate :slightly_smiling_face: