I'm just trying to search through a two dimensional array of strings.
The results in found are correct, but the row isn't pushed (correctly) into the array.
The browser shows me this:
function filterItems(arr, query) {
return arr.filter(function(el) {
return el.toLowerCase().includes(query.toLowerCase());
});
}
function FilterArray(unfiltered_array, searchphrase) {
var filtered_array = [];
for (var i = 0; i < unfiltered_array.length; i++) {
var row = unfiltered_array[i];
var found = filterItems(row, searchphrase);
if (found.length) {
console.log(row);
filtered_array.push(row);
}
}
return filtered_array;
}
const filtered = FilterArray([
["LC53005", "bob", "lc56778"],
["FP53001", "john", "dog"]
], "lc5");
console.log({
filtered
});
and I was searching for LC53005.
Any ideas?
Clearer approach with the expected result !