loader image

JavaScript program to print multiplication table

Design a JavaScript program to display the multiplication table by accepting the number and the limit.

<html>

<body>

    <h1>Multiplication Table</h1>
    Enter a number:
    <input type="text" id="num" /><br /><br />
    Enter limit:
    <input type="text" id="limit" />
    <input type="button" value="Find" onClick="multiply()" />
    <p id="result"></p>
    <script>
        function multiply() {
            var n = document.getElementById('num').value;
            var l = document.getElementById('limit').value;
            var out = "";
            for (var i = 1; i < l; i++) {
                out = out + i + " * " + n + " = " + i * n + "<br/>";
            }
            document.getElementById("result").innerHTML = out;
        }
    </script>

</body>

</html>
Output
multiply js
Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Arun

This website really helps me to study for my exams
Thanks a lot !

Scroll to Top