In the process of learning JavaScript, the first time to contact the loop statement when the multiplication table to practiced hand, here I will be my practice posted here, I hope to give the same beginners and I a little help, but also hope that the great God can feel free. First of all, take a look at the multiplication table what it looks like, do not tell me that everyone can remember clearly oh! Secondly, the multiplication table is a table, there are rows and columns, using nested loops to output the inevitable use of two parameters, with I for the line number, J for the column number. In addition, we look at the entire table as a string, so we set the string to Res. The code is as follows: var res = "", i,j; then, loop through the line number and loop through the column number in the line number loop. for (i=1;i<=9;i++) {//j<=i will not be stepped output, if it is j<=9, then the output is 9x9 rectangle table for (j=1;j<=i;j++) {res + = i + "x" + j + "=" + I*j + "& ; nbsp   ";} NewLine res + = "<br>";} Finally, output res to the HTML document with the following code: document.getElementById ("Div01"). InnerHTML = res; all codes are as follows: <body><div id= "DIV01" > </div><script>var res = "", I,j;for (i=1;i<=9;i++) {for (j=1;j<=i;j++) {res + = i + "x" + j + "=" + i*j + "   ";} Res + = "<br>";} document.getElementById ("Div01"). InnerHTML = res;</script></body> The code and explanation of the multiplication table using JavaScript output is the above, The first time to write this summary, some do not know what to write the feeling, the wrong place please forgive and feel free.
JavaScript applet--using nested loops to output multiplication tables