21. JavaScript Program to Display 1 to 99 numbers in 5 columns Sequentially.
How does this program work?
- In this program we are going to learn about how to display 1to 99 numbers in 5 columns sequentially using JavaScript.
- In this program we are using for loop to display numbers.
- And 'if' condition is used to print 20 numbers on each line sequentially.
Here is the code
<html>
<head>
<title>JavaScript program to display 1 to 99 numbers in 5 columns sequentially</title>
</head>
<body>
<div id="num"></div> </body>
<script type="text/javascript">
var i;
//To print 1 to 99 numbers sequentially
for(i = 1; i <= 99; i++)
{
//To print 20 numbers on each line
if(i%20 == 0)
{
document.write("</br>");
}
document.writeln(i);
}
</script>
</html>