SOURCE

for (let i = 0; i < 4; i++) {
    let out = "";
    for (let j = 0; j < 3 - i; j++) {
        out += " ";
    }
    for (let j = 0; j < 2 * i + 1; j++) {
        out += "*";
    }
console.log(out);
}
for (let i = 0; i < 3; i++) {
    let out = "";
    for (let j = 0; j < i + 1; j++) {
        out += " ";
    }
    for (let j = 0; j < 5 - 2 * i; j++) {
        out += "*";
    }
console.log(out);
}
console 命令行工具 X clear

                    
>
console