Untitled
unknown
plain_text
4 years ago
597 B
6
Indexable
function stampAsterischi(indice, x) {
let asterisco = "";
for (let i = 0; i < indice; i++) {
asterisco = asterisco + "*";
}
let spazi = ""
for (let i = 0; i < x; i++) {
spazi = spazi + " "
}
console.log(spazi + asterisco);
}
function clessidra(numero) {
let x = 0
for (let i = 0; i < numero; i++) {
stampAsterischi((numero - i) * 2 - 1, x)
x = x + 1
}
x = x -1
for (let i = numero - 2; i >= 0; i--) {
x = x - 1
stampAsterischi((numero - i) * 2 - 1, x);
}
}
clessidra(10)Editor is loading...