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

168
Visualizações
JavaScript function stops working when having multiple if statements

I have JavaScript code. My if statement is not working as I hope it to do so. Inside of my for loop I have 2 if statements. The issue is that when using 2 if statements my alert function is not working. If I remove either the first or the second if statement where I only have 1 if statement the alert function work. I need to check for both condition

does not work

const getDbData = (selections) =>{
    // db select query goes here
    (sqlTx, res) => {
        console.log('Midi map check [Scenes] completed successfully');
        let len = res.rows.length;

        // Check for items here
        if (len > 0) {
          let sceneAssignedResults = false;
          let groupAssignedResults = false;
          for (let i = 0; i < len; i++) {
            let item = res.rows.item(i);

            // remove this if or the next if then everything works
            if (item.type === 'scene') {
              sceneAssignedResults = true;
            }

            if (item.type === 'scene' && selections.item.type !== 'scene') {
              groupAssignedResults = true;
            }
          }

        

          alert(`${sceneAssignedResults} ${groupAssignedResults}`);
        }
      }
}
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