6 thoughts on “JavaScript code to display Multiplication table”

  1. the above code is not a true multiplication table, it’s simply showing the multiples of the number you type. Below would be a true multiplication table:

    Multiplication Table


    function multiply() {
    var col, row, answer, multiplier; //declare variabels
    document.write(‘Multiplication Table’ + ”);
    document.write(‘Refresh the browser to use a different table multiplier’ + ”);
    multiplier = prompt(“Enter a Multiplication Table max multiplier, ie; 10 for 10×10”, “”)
    multiplier = parseInt(multiplier); //parse the num to number

    document.write(”); //setup the table
    for( col = 1; col <= multiplier; col++) {
    document.write('’ + ‘ ‘);
    for( row=1; row <= multiplier; row++) {
    answer = col * row; //multiply columns * rows, store in variable answer
    document.write( '’ + ‘ ‘ + answer + ‘ ‘ + ”);


    window.onload = multiply;


Leave a Reply to anil prasanna Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.