Project time
Let's build a times-table printer: choose a number and a range, and it neatly prints the whole table. Then you'll extend it to print several tables at once.
The plan
- Keep the number and range in variables so they're easy to change.
- Loop through the range.
- Build each line with a template literal: 7 x 3 = 21.
const table = 7;
const upTo = 3;
for (let i = 1; i <= upTo; i++) {
console.log(`${table} x ${i} = ${table * i}`);
}