Friday, 5 June 2020

Create html page and display the even numbers between 0 to 10 using for loop in javascript function.


<!DOCTYPE html>
<html>
<head >
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
        <script type="text/javascript">
            var i = 2;
            for(i=2;i<=10;i++)
                 {
                     if(i%2==0)
                document.write("The number is: " + "<b>" +i + "</b>");
                document.write("<br/>");
            }
        </script>
        </div>
        </form>
</body>
</html>


Output:

Posted By: pankaj_bhakre

No comments:

Post a Comment