function filteredArray(arr, elem) {
"use strict";
let newArr = [];
let len = arr.length;
for(let i = 0;i <len; i++){
/* Assume that all of the elements of the subarray do not match elem (initialize a Boolean flag variable to true)*/
if(arr[i].indexOf(elem) === -1){
return true;
}
for(let j = 0;j<arr[i].length;j++){
// Check if the current element in sub array is equal to elem.
if(arr[i][j] === 3){
return false;
break;
}
/* If it is equal, then set the value of your flag variable to be false AND stop break out of loop*/
}
}
// If the flag variable is still true then push the sub array into newArr
newArr.push(arr[i]);
console.log(newArr);
return newArr;
}
console.log(filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3));
function filteredArray(arr, elem) {
"use strict";
let newArr = [];
let len = arr.length;
let value ;
for(let i = 0;i <len; i++){
/* Assume that all of the elements of the subarray do not match elem (initialize a Boolean flag variable to true)*/
if(arr[i].indexOf(elem) === -1){
value = true;
console.log(value);
}
for(let j = 0;j<arr[i].length;j++){
// Check if the current element in sub array is equal to elem.
if(arr[i][j] === elem){
value = false;
console.log(value);
break;
}
/* If it is equal, then set the value of your flag variable to be false AND stop break out of loop*/
}
if(value === true){
newArr.push(arr[i]);
}
}
// If the flag variable is still true then push the sub array into newArr
return newArr;
}
console.log(filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3));