Trying to remove an entire array if within my data if it contains a certain value.
What would be the best approach to this problem?
data = [['true', 'visiting-today', 'DVM-Wiessman','J-001'],
['false', 'visiting-tommorrow', 'DVM-Stevens','K-001'],
['true', 'visiting-tommorrow', 'DVM-Stevens','Z-001'],
['false', 'visiting-tommorrow', 'DVM-Kon','J-001']]
var del_value = 'J-001';
function remove_from_list(list) {
for( var i = 0; i < list.length; i++) {
for( var j =0; j < Object.keys(list[i]).length.length; j++) {
if(del_value == list[i][j]) {
list.splice(list[i], 1);
}
}
}
return list;
}
actual output
data =
[['true', 'visiting-today', 'DVM-Wiessman','J-001'],
['false', 'visiting-tommorrow', 'DVM-Stevens','K-001'],
['true', 'visiting-tommorrow', 'DVM-Stevens','Z-001'],
['false', 'visiting-tommorrow', 'DVM-Kon','J-001']]
desired result — to remove all arrays that have the value 'J-001'
data =
[['false', 'visiting-tommorrow', 'DVM-Stevens','K-001'],
['true', 'visiting-tommorrow', 'DVM-Stevens','Z-001']]