Print a list from n times 1 to n times 9


Posted by Christy on 2022-04-19

Description: Write a function named table that accepts a number n and print the list from n times 1 to n times 9

table(1)
1*1 = 1
1*2 = 2
1*3 = 3
1*4 = 4
1*5 = 5
1*6 = 6
1*7 = 7
1*8 = 8
1*9 = 9

table(7)
7*1 = 7
7*2 = 14
7*3 = 21
7*4 = 28
7*5 = 35
7*6 = 42
7*7 = 49
7*8 = 56
7*9 = 63

Answer:

function table(n) {
  for (let i = 1; i <= 9; i++) {
    console.log(n + "*" + i + "=" + n * i);
  }
}

table(3);









Related Posts

有關 PySpark 的那些事

有關 PySpark 的那些事

LeetCode JS 1. Two Sum

LeetCode JS 1. Two Sum

資料庫初探:RDBMS & NoSQL

資料庫初探:RDBMS & NoSQL


Comments