4 of 5 check marks... last one i need help please

Hi guys!! I’m doing Basic Data Structures: Iterate Through All an Array’s Items Using For Loops,
I think that i have problems with the last case due to it is reading (the element 18 like 1 and 8) i don’t know and i can’t find what i need to put in my code to complete the last one!! All the other i passed… Thank you!!!

  var newArr = [];
  // change code below this line
for (var i = 0; i < arr.length; i++) {
 if (arr[i].includes(elem) !== true) {
   newArr = [arr[i]]
  }
}
    // change code above this line
  return newArr;
}

// change code here to test different cases: */
console.log(filteredArray([[10, 8, 3], [14, 6, 23], [3, 18, 6]], 18))```

You must add all sub-arrays that does not contain the element value.

console.log(filteredArray([[10, 8, 3], [14, 6, 23], [3, 18, 6]], 18))

Since we don’t want sub-arrays with the element 18 in this case, our function should return [[10, 8, 3], [14, 6, 23]].

Your logic is kind of correct but you’re overwriting your newArr instead of adding sub-arrays into it.

newArr = [arr[i]]

In our case, our loop goes like this:

  • Check [10, 8, 3], does not contain 18, newArr = [10, 8, 3]
  • Check [14, 6, 23], does not contain 18, newArr = [14, 6, 23]

Got it? Instead of setting our newArr again, we should push these sub-arrays into it. Let me know if you could get it to work.

Thank you so much!!! :grimacing::raised_hands:t4: finally