js-exercises/ejer9/9.js

21 lines
518 B
JavaScript
Raw Normal View History

2024-01-18 10:43:05 +01:00
function multiplicador(multipl) {
2024-01-18 11:42:18 +01:00
document.write(`<p align=center>`)
2024-01-18 10:43:05 +01:00
for (let i = 1; i < 11; i++) {
document.writeln(`${multipl} * ${i} = ${i * multipl}<br>`)
}
// Adding horizontal line for visual clarity
2024-01-18 11:42:18 +01:00
document.write(`</p>`)
2024-01-18 10:43:05 +01:00
document.writeln(`<hr>`)
}
function main() {
2024-01-18 11:42:18 +01:00
// Declaring multi to hold the first number
2024-01-18 10:43:05 +01:00
var multi = 1;
// For loop that and for every time the multiplier function ends, run multi++ to sum
for (let a = 1; a < 11; a++) {
multiplicador(multi)
multi++
}
}