Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
Can it be checked if 2 values are there In react

I have an Api which is fetching Email and password. After that I am seeing if that email and password exists by the following functions:

function EmailCheck(Email){
  return arr.some(function(el) {return el.attributes.Email === Email;})}

And same for password just changing email to password but if email is of one object and password ob another objects it passing. Is there any way I can check if Password is in Object where Email is.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

what do you mean by another object its passing? do your objects look like this

emailObject = {
'email': 'some@email.com'
}

passwordObject = {
'password': 'password'
}

or like this

authObject = {
'email':'some@email.com'
'password': 'password'
}

if it is like the latter you could just use one function

authCheck(email,password){
   return arr.some((el)=>{
      if(el.email != email){
        return false
      }
      return el.password == password
   })
}

however this may not be the best approach. it kind of depends on what your database looks like and how everything is strung together but what i have done in the past is something like

checkUser(email, password){
  return arr.find((user)=>{
    return user.email === email && user.password === password
  })
}

that way it finds the first (should be only) object, and returns it to be used. this will also allow you to get the index in the array if needed or do ther checks on the same object once you have gotten it. (like removing the password check and doing that as a separate function)

checkUser(email, password){
  let user = arr.find((user)=>{
    return user.email === email
  })
  if(user){
    //do password check and other operations here
  }
  return user // for anything that needs to be done with the user
}

about 4 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 Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!