Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

115
Vistas
Seemingly empty Array after push

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:

enter image description here

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?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Clearer approach with the expected result !

var unfiltered_array = [
  ["LC53005", "bob", "cat"],
  ["FP53001", "john", "dog"]
];

function filterItems(arr, query) {

  return arr.filter(function(el) {
    return (el.toLowerCase().includes(query.toLowerCase()));
  })
}

function FilterArrayMap(unfiltered_array, searchphrase) {
  return unfiltered_array.map(k => {
    return filterItems(k, searchphrase);
  }).flat();
}

console.log(FilterArrayMap(unfiltered_array, "LC53005"));

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda