The text in the input immediately just skips to 99. Is there any way I can make it display the i variable, while it's iterating?
<input id="test" type="text">
<script>
for(let i = 0; i < 100; i++){
document.getElementById("test").value = String(i);
}
</script>
You can use setInterval to call your function at whatever interval you like:
let i = 0;
setInterval(function() {
if (i < 100) {
document.getElementById("test").value = String(i);
i++;
}
}, 100)
<input id="test" type="text">
Your way won't work without some sort of delay because the entire loop executes in milliseconds and is too fast for the eye to see.