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

136
Vistas
Search doesn't work when it has spaces or different type case characters

I'm working on a search that partly works but it has some bugs, the first one is that doesn't search the characters that differen in case, for example: StackOverflow is not 'Stackoverlow`, but I want to match it even if they differ in casing.

The other problem is that doesn't search the white spaces, as long as is without spaces it works but when I try to search for example: Stack Overflow, then it doesn't find the Stack Overflow even if it exits.

This search is that made to search all values inside an object. Waiting for better code, let's see!

Here is the code:

const findIn = (arr, query) => {
  return arr.filter((obj) =>
    Object.keys(obj).some((key) => {
      if (typeof obj[key] === 'string') return obj[key].includes(query);
    })
  );
};

As requested here is how the object looks: screenshot

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

0

You can solve your problem by format your string to lowercase and remove spaces and also in your obj.

  const findIn = (arr, query) => {
     let queryFormatted = (query.toLowerCase()).trim();
     return arr.filter((obj) =>
       Object.keys(obj).some((key) => {
        if (typeof obj[key] === 'string'){
          return ((obj[key].toLowerCase()).trim()).includes(queryFormatted);
          }
     })
  );
};
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