Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

135
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda