Task
OUTCOME: 1.2
Describing the purpose of a range of programming constructs and how they work
Your client has requested a program that will print a multiplication table.
The program should request a number from the user.
The program well then print the range of multiplication sums from 0 to 12 for that number.”
Solution
Enter a number to multiply:
Enter the range for calculation:
Final result
result here


Show Code
Code
| function multiply() { | |
| //program to generate a multiplication table | |
| //get input from the user | |
| let number = document.getElementById(‘num’).value; | |
| let range = document.getElementById(‘limit’).value; | |
| //declare empty variable | |
| let table =””; | |
| //setup counter | |
| for(let i = 1; i <= range; i++) { | |
| //update variable | |
| table = table + i + ” * ” + number + ” = ” + i * number + “<br />”; | |
| } | |
| //display the result | |
| document.getElementById(“multiplication-results”).innerHTML = table; | |
| } |
