<html>
<body>
<p>Click the button to loop through a block of code as long as i is less than 5.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var text = "";
var i = 0;
while (i < 5) {
text += "<br>The number is " + i;
i++;
}
document.getElementById("demo").innerHTML = text;
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_state_while by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:01:34 GMT -->
</html>