如何实现乘法口诀表

js如何实现打印乘法口诀表?

代码如下:

let str = "";
for (let i = 1; i < 10; i++) {
  for (let j = 1; j <= i; j++) {
    str += (j + "×" + i + "=" + j * i + ' ')
  }
  str += '\n'
}
console.log(str)

通过2层for循环即可实现打印乘法口诀表啦!

posted on 2021-12-08 21:30  久居我梦  阅读(53)  评论(0编辑  收藏  举报

导航