Create a for loop that output the numbers 1 3 5 7 9 with line breaks between each number. - Javascript Statement

Javascript examples for Statement:Quiz

Description

Create a for loop that output the numbers 1 3 5 7 9 with line breaks between each number.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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

<script>
var text = "";
var i;// ww  w.ja  va2s .c o m

for (i = 1; i < 10; i = i + 2) {
    text += i + "<br>";
}

document.getElementById("demo").innerHTML = text;
</script>

</body>
</html>

Related Tutorials