Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

143
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda