Loops - Iterate Through All an Array's Items Using For Loops

PHOTO EMBED

Tue Apr 26 2022 23:20:43 GMT+0000 (Coordinated Universal Time)

Saved by @Luduwanda #javascriptreact

function filteredArray(arr, elem) {
  let newArr = [];
  // Only change code below this line
  // arr.length = 4

for(let i = 0; i < arr.length; i += 1){

//["flutes", 4] ()=== arr[1])--> 2 is not showing up ...i dont understand????

if(arr[i].indexOf(elem) === -1){
newArr.push(arr[i]);
}
}
  // Only change code above this line
  return newArr;
}

console.log(filteredArray([["trumpets", 2], ["flutes", 4], ["saxophones", 2]], 2));
content_copyCOPY