OneCompiler

JavaScript program to print table for given number

6899

Following program shows you how to print table for given number.
In this program we get number from user and print that number table using for loop

var input  = prompt("Enter the number:");
for (var i = 1; i <= 10; i++) {
console.log(input + " * " + i + " = " + input * i);
}

Output:

Enter the number:
3

3 * 1 = 3
3 * 2 = 6
3 * 3 = 9
3 * 4 = 12
3 * 5 = 15
3 * 6 = 18
3 * 7 = 21
3 * 8 = 24
3 * 9 = 27
3 * 10 = 30