console
document.write("<table>");
var str = "js九九乘法表";
document.write("<h1>" + str + "</h1>");
for ( var x = 1; x <= 9; x++) {
document.write("<tr>");
for ( var y = 1; y <= x; y++) {
document.write("<th>" + x + "*" + y + "=" + (x * y) + "</th>");
}
document.write("</tr>");
}
document.write("</table>");
class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
zx() {
for (let i = this.x; i <= this.y; i++) {
let str = "";
for (let j = this.x; j <= i; j++) {
str += "|" + i + "*" + j + "=" + (i * j)+"\t";
}
str += "|";
console.log(str);
}
}
dx(){
for (let i=this.y;i>=this.x;i--) {
let str="";
for (let j=this.x;j<=i;j++){
str += "|" + i + "*" + j + "=" + (i * j)+"\t";
}
str+="|";
console.log(str);
}
}
}
var ss = new Point(1, 9);
ss.zx();
ss.dx();
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>九九乘法表</title>
</head>
<body>
</body>
<script src="js/app.js"></script>
</html>