reflection :
After learning process control and condition judgment , We can use js Print all kinds of 99 multiplication tables
No matter what kind of triangle 99 multiplication table is printed , We should all find a regular place , For example, what is the law of the numbers in the first column , What is the law of the number in the first line , As long as we find commonalities , The 99 multiplication table is very simple .
Attention :
How to control line breaks ?
console.log() The default is to print one line at a time , At this time, we need to splice the multiplication numbers in one line together through strings , When this line is over , It's in the outer layer for Print in loop , Not in the inner circle .
How to realize the interval after multiplying every two numbers ?
Use escape characters \t , amount to tab key
What do we do with those empty in front ?
In fact, the space is used , Because the space is also regular , You also need to cycle through the print , About two \t Equivalent to (ij=ij).
When we were testing , You can use some more prominent characters instead , such as Fine , When the effect comes out, it will be changed into a space .
<body> <script> // multiplication table for (var i = 1; i <= 9; i++) { var s = ''; for (var j =
1; j <= i; j++) { s += j + '*' + i + '=' + (i * j) + '\t' } console.log(s); }
console.log(
"===================================================================") for (var
i= 1; i <= 9; i++) { var t = ''; for (var j = i; j <= 9; j++) { t += i + '*' + j
+ '=' + (i * j) + '\t' } console.log(t); } console.log(
"===================================================================") for (var
i= 1; i <= 9; i++) { var u = ''; for (var k = 1; k < i; k++) { u += "\t\t" } for
(var j = i; j <= 9; j++) { u += i + '*' + j + '=' + (i * j) + '\t' } console.log
(u); } </script> </body>
Technology