How to Create a Javascript Multiplication Table?

In This blog, we are going to learn, How to Create a Javascript Multiplication Table?

Here, an example of a simple multiplication table is given in which the user is asked the number of rows and columns he wants.

<html>
<head>
  <title>Multiplication Table</title>
  <script type="text/javascript">
    var rows = prompt("How many rows are there for your multiplication table?");
    var cols = prompt("How many columns are there for your multiplication table?");
    if(rows == "" || rows == null)
            rows = 10;
    if(cols== "" || cols== null)
            cols = 10;
    createTable(rows, cols);
    function createTable(rows, cols)
    {
      var j=1;
      var output = "<table border='1' width='500' cellspacing='0'cellpadding='5'>";
      for(i=1;i<=rows;i++)
      {
        output = output + "<tr>";
        while(j<=cols)
        {
            output = output + "<td>" + i*j + "</td>";
             j = j+1;
           }
            output = output + "</tr>";
            j = 1;
    }
    output = output + "</table>";
    document.write(output);
    }
  </script>
</head>
<body>
</body>
</html>

Hope this blog is helpful for you ,Thanks for reading this blog.

How to Create a Javascript Multiplication Table?expoundsofttechsolution Install node js on Go Daddy Shared hosting.