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
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
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!