• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

145
Vistas
.find() Is finding values elements that are not apart of the search criteria

I am using .find() on the following json object, which I've named records:

[
  {
    "_id": "61f9da9fcc6888f201f722cb",
    "firstName": "joe",
    "lastName": "jergen",
    "email": "joe@outlook.com",
    "status": "active",
    "amount": "5600"
  }
]

I then try to find a user in my object using find():

let userProfile = records.find((x) => (x.email = "peter@google.com"));

When I log userProfile it seems to pull joe@outlook.com still even though the user is not in the object. The desired behaviour would be null/undefined

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

0

You probably want to do x.email === "peter@google.com"

= is an assignment operator while === is a comparison operator.

about 3 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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda