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

180
Vistas
How to do spelling check with each of the property of an array of Object?

I am developing a program where a user will pass an argument and the program will give almost the same match of the result that it will find in an array of Object. So I have an array of object which is coming from a database so when my user will pass a name the search criteria on the array of object should work something like this suppose the user have passed a name called Jack Ma now on my array there are following objects like

[
{
name: "Jacky Ma"
},
{
name: "Jacky Man"
},
{
name: "Jack Mun"
},
{
name: "Jacob Ma"
},
{
name: "Jack Ma"
}
]

so for this following case Jacky Ma, Jack Mun, Jacob Ma should get retuned in an array of object. Only thing the program should check is the spelling of the each words matches with spelling of the words that are in the object lowerCase upperCase do not matter here for both words or if there is one or more than 2. The only thing it should check is the spelling of the words if the first word spelling matches with the spelling of the first word or 2nd word spelling matches with 2nd word of the object only then it should return. If neither or one do not get matched it should return empty array.

can anyone help me how can I do this ? Thanks in Advance.

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

0

In your current code, you are comparing the whole String "Jack Ma" and not "Jack" and "Ma". You need to split the name property and the string, loop over them and compare:

const filterData = searchClan.items.filter(
    n => {
        const splittedName = n.name.toLowerCase().split(' ');
        const splittedArgs = validateArgs.toLowerCase().split(' ');
        return splittedArgs.some((argument, index) => splittedName[index] && splittedName[index] === argument)
    });

The "some" method returns true if one of the element (at index "index" ) in the splittedArgs array matches with the element at index "index" in the splittedName array.

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