Write a JavaScript program to print the multiplication table of a number

Description: Print the multiplication table of 7, from 1 to 10.

Hint:

  • Use a for loop from 1 to 10.

JavaScript multiplication table program

const num = 7;

for (let i = 1; i <= 10; i++) {
  console.log(`${num} x ${i} = ${num * i}`);
}

Output:

Tutorials Class - Output Window

7 x 1 = 7
7 x 2 = 14
7 x 3 = 21
7 x 4 = 28
7 x 5 = 35
7 x 6 = 42
7 x 7 = 49
7 x 8 = 56
7 x 9 = 63
7 x 10 = 70

How it works

  • The loop runs with i from 1 to 10.
  • The template literal prints the line with the numbers.

Read JavaScript Loops.


Learn more about the similar topics:
Tutorials
JavaScript Conditional Statements
JavaScript Loops
Exercises & Assignments
Write a JavaScript program to check even or odd number
Write a JavaScript program to find the largest of three numbers
Write a JavaScript program to check leap year
Write a JavaScript program to print the multiplication table of a number
Write a JavaScript program to find the factorial of a number
Write a JavaScript program to print the Fibonacci series
Write a JavaScript program to check prime number
Interview Questions & Answers
What is the difference between for…in and for…of?