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

161
Views
Un programa de JavaScript donde se genera un número y el usuario intenta adivinarlo. Mi problema es de entrada

Tengo el aleatorizador funcionando, mi problema es obtener la entrada del usuario. Parece que no puedo averiguar cómo activar la entrada. Usé "window.alert" así como "console.log" pero no pasa nada. soy muy nuevo en esto

Este es mi HTML:

 <DOCTYPE html> <html> <body> <h2> Guessing For Random Numbers! </h2> <p> A random number between one (1) and ten (10) will be selected. Try to guess the result! Input your answer: </p> <script src= "RandomNumberMaker.js"> </script> </body> </html>

Este es mi JavaScript:

 var number = window.alert("Please Enter A Number Between One and Ten: "); var random = Math.floor(Math.random() * 10) + 1; if (random == number) { document.write ("Your Guess Was Correct!"); document.write(random); }else { document.write ("Your Guess Was Incorrect. The Correct Answer Was: " + random); }

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

0

Puede usar prompt para obtener una input de usuario como tipo de alerta

 var number = window.prompt("Please Enter A Number Between One and Ten: "); var random = Math.floor(Math.random() * 10) + 1; if (random == number) { document.write("Your Guess Was Correct! It is" + number); document.write(random); } else { document.write("Your Guess Was Incorrect. The Correct Answer Was: " + random + " not " + number); }
 <h2> Guessing For Random Numbers! </h2> <p> A random number between one (1) and ten (10) will be selected. Try to guess the result! Input your answer: </p>

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!