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

140
Views
Why can't this if statement do 2 things?

I'm trying to update the counter and use it so I can switch the question each time but it only works if i remove the counter +=1, help please!

Code below:

const questions= [
    "What is Orochimaru's last name?",
    "What is Sasuke's least favorite food?",
    "What was Itachi's girlfriend's name?"
]

const correctAnswers= ["None", "sweets", "Izumi"]

const counter= 0 //for keeping track of answer alignment
//const score= 0 //keeps track how many they get right 


submitButton.onclick= function(){

    if (answer_a.checked == true && labelA.textContent == correctAnswers[counter]) {
        counter +=1 //will work if I delete counter+=1 and replace counter as 1
        questionContainer.innerHTML = questions[counter] 
    }
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!