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

164
Views
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
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!