Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

131
Vistas
JavaScript while loop won't increment properly for HTML document

I have been trying to understand this task for school but I can't wrap my head around it. The program should display the range using a while loop (not a for loop), starting at the user input "Starting Point", and continuing until the user input "Limit" is reached. Each number is incremented by the amount that that user specifies in the "Increment" input.

Thank you!

function button() {

  let count = document.getElementById('startingPoint').value;
  let limit = document.getElementById('limit').value;
  let step = document.getElementById('increment').value;

  while (count <= limit) {
    document.getElementById('output').innerHTML += count + ' ';
    count += step;
  }
}
<body>
  <!-- Ask user for three inputs -->
  <input id="startingPoint" type="number" placeholder="Starting Point" />
  <br />

  <input id="limit" type="number" placeholder="Limit" /> <br />

  <input id="increment" type="number" placeholder="Increment" /> <br />

  <!-- Button to initiate function -->
  <br />
  <button onclick="button()">Display</button>
  <br />

  <!-- Container for output(s) -->
  <div id="output"></div>
</body>

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda