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

173
Views
¿Puedo tener múltiples respuestas para una pregunta en js?

Estoy creando un juego de trivia para mi sitio web, pero quiero tener múltiples respuestas para las preguntas, solo para que sea un poco más fácil de responder para las personas. Todo lo que intenté salió mal, entonces, ¿qué puedo hacer? JavaScript:

 function quiz() { var score=0; var totalQuestions=3; alert("Welcome to my trivia game!"); alert("Make sure you answer all the questions."); var q1=prompt("What war occured in 1812?"); if(q1=="the 60 year war" ) { score=score+1; alert("Correct!"); } else { alert("Incorrect! The correct answer is the 60 year war!"); } var q2= prompt("When did the revolutionary war start?") ; if(q2=="1775" ) { score=score+1; alert("Correct!"); } else { alert("Incorrect! The right answer is 1775!"); } var q3=prompt("If you're trying to fail and you succeed, did you fail or succeed?"); if(q3=="you succeeded" ) { score=score+1; alert("Correct!"); } else { alert("Incorrect! You succeeded!"); } alert("You got " + score + " questions out of " + totalQuestions + " correct." );

}

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede usar O "||" condición

 if(q1=="the 60 year war" || "SECOND ANSWER HERE ") { score=score+1; alert("Correct!"); } else { alert("Incorrect! The correct answer is the 60 year war!"); }
about 4 years ago · Juan Pablo Isaza Report
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!