Make while loop start counting downwards from 10 and stop at 1. The output should be 10 9 8 7 6 5 4 3 2 1 with line breaks. - Javascript Statement

Javascript examples for Statement:Quiz

Description

Make while loop start counting downwards from 10 and stop at 1. The output should be 10 9 8 7 6 5 4 3 2 1 with line breaks.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="demo"></p>

<script>
var i = 10;
while (i > 0) {
    document.getElementById("demo").innerHTML += i + "<br>";
    i--;/*from w ww  .  j  a  va 2 s  .c  o  m*/
}
</script>

</body>
</html>

Related Tutorials