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

133
Views
¿Cómo tomaría una variable como N y la cambiaría a un número que ingresa un usuario?

Estoy escribiendo un código que le pide al usuario que ingrese un número en un mensaje de ventana. Cuando desaparezca el indicador, quiero que haya una declaración que diga "Elija un número entre 1 y n" y que n se reemplace por el número que ingresen. ¿Es algo que puedo hacer en el lado HTML o se hace a través de JavaScript? Soy muy nuevo en estas cosas. He estado buscando en este sitio todo el día y tratando de resolver esto de otras publicaciones, pero no he tenido suerte. Agradezco la ayuda.

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"> <title>Higher Lower</title> </head> <body> <div class="container"> <h1>Higher - Lower</h1> <p>Guess a number between 1 and n.</p>
 let valid_input = false; let num_range, input; let number_guesses = []; // validating that max input is positive while(!valid_input) { input = window.prompt("Enter a positive, max value:"); num_range = Number(input); if(num_range != NaN && num_range > 0) { valid_input = true; } } document.getElementById('button').addEventListener('choice', do_guess)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Give some id to <p> tag for suppose - <p id="range">Guess a number between 1 and n.</p> and add **document.getElementById("range").innerHTML = "Guess a number between 1 and " + input;** right next to **input = window.prompt("Enter a positive, max value:");**
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!