[enter image description here][1]
let x = 4; let text = ""; for(let i = 1; i <= x; i++) { for(let j = 1; j <= x - i; j++) { text += " "; } for(let k = 0; k < 2 * i - 1; k++) { text += "*"; } text +="\n"; } console.log(text);
---La salida que quiero es así. Soy nuevo en esto. Gracias de antemano [1]: https://i.stack.imgur.com/AJvaZ.png
Pequeño cambio:
let x = 4; let text = ""; for(let i = 1; i <= x; i++) { for(let j = 1; j <= x - i; j++) { text += " "; } text += "*"; for(let k = 0; k + 1 < i; k++) { text += " *"; } text +="\n"; } console.log(text);