JavaScript code to find table of any number

Write a Javascript code to Print Multiplication Table. In this JavaScript code example, Let’s create a JS funcation to find table of any number and print it on the HTML. In this below task, Create a simple JS popup that will take the input from user and print the table of entered number.

Javascript is a scripting language that enables you to create dynamically updating content, control multimedia, animate images, and pretty much everything else. It is used for creating web pages. check details JavaScript Tutorial

Algorithm to Print Multiplication Table

  • Enter the number for which multiplication table is to be printed.
  • Initialize var i=0
  • Loop for (i=1;i<=10;i++)  num +”x” + i+ “=” +num*i
  • Print table.

JavaScript code to find table of any number

<!DOCTYPE html>
  <title>Multiplication Table</title>

    var num=prompt("Enter the number");
    var i=0;
    document.write('<table border="5" cellspacing="5"');
      document.write("<tr><td bgcolor=red>"+ num +"x" + i+ "=" +num*i + "</td></tr>");





In this way, we learned how to print multiplication tables in Javascript.