📅  最后修改于: 2022-03-11 15:03:34.778000             🧑  作者: Mango
// Display pyramid of number using JavaScript
function pyramid(n) {
for (let i = 1; i <= n; i++) {
let str = ' '.repeat(n - i);
let str2 = '*'.repeat(i * 2 - 1);
console.log(str + str2 + str);
}
}
pyramid(5);