• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

143
Views
.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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error