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
why does the code not work and return correct in the if statement

var question_list = ["What is 1 + 1", "What is 2 + 2"] 
var answer_list = [2, 4]
let currentNumber = 0;
let scoreboard = 0;

function submit() {
    let user_answer = $('#question-number').val()
    console.log(user_answer)
    console.log(answer_list[currentNumber])
    if (user_answer === answer_list[currentNumber]) {
        console.log("correct");
    } else {
        console.log("eror");
    }
}
submit();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id="question-number" />

I am not sure why the if else statement gives me the else answer because the terminal will print out 2 2 eror

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!