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>