JavaScript Program to Print HTML Heading from <H1> to <H6>

Write a JavaScript program to print html heading from <h1> to <h6> using while loop.



Source Code
<html>

<head>
    <title>HTML headings</title>
</head>
<body>
<script type="text/javascript">
    var i = 1;

    while(i <=6 ) 
    {
        document.write("<H" + i + "/>This is heading " + i + "</H" + i + ">");
        i++;
    }
</script>
</body>
</html>
Output





"Coding Hub - Learn to code" app now available on Google Play Store