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

159
Visualizações
How to return an Object Value if you have a specific key in your Object?

// If successfully created let sampleObject = { response: 'Generated ID from the application' }

// If error let sampleObject = { errorLog: 'Generated error message from the application' }

I have an object that returns different keys depending if it is successful or an error (see above sample code). If it is successful, it has a key of 'response' and has a value of ID generated, otherwise it has a key of 'errorLog' and has a value of the error message. Now I want to run an if statement with those keys. For example, if the key 'response' is present, I want to alert the user for the generated ID for successfully creating the data. But if the key 'errorLog' is present, I want to alert the user for the error message.

Can someone help me?

about 4 years ago · Juan Pablo Isaza
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