步骤构思:
1、使用for循环打印99乘法表
2、9行9列,双for,空字符串,转义符间距tab、换行newline
3、变量储存--数字、每行每列
展示一
function getForm() {
var num = ‘‘;
for (var rows = 1; rows <= 9; rows++) {
for (var cols = 1; cols <= rows; cols++) {
num += cols + ‘ב + rows + ‘=‘ + rows * cols + ‘\t‘;
}
num += ‘\n‘;
}
return num;
}
console.log(getForm());
展示二
function getTable() {
var str = ‘‘;
for (var row = 9; row > 0; row--) {
for (var col = 1; col <= row; col++) {
str += col + ‘ב + row + ‘=‘ + row * col + ‘\t‘;
}
str += ‘\n‘;
}
return str;
}
console.log(getTable());