Good evening and as always, thanks in advance. I did an exercise to write with asterisks in a pyramid shape (I explain it better in this code snippet)
function pyramid(numPisos) {
for (let i = 0; i < numPisos; i++) {
let piso = '';
for (let j = 0; j < i + 1; j++) {
piso = piso + '*';
}
console.log(piso)
}
}
pyramid(5);
and the next thing I want to do is make this same pyramid right-aligned, instead of left-aligned as it is now. I know I need another for* loop between the two existing ones, but after trying more than 100 ways the only thing I get is that the pyramid has 5 spaces on each line before writing the asterisk. That is, I can only move it to the right but not Change your lineup. In case I give rise to many doubts, my goal would be to leave it like this:
*
**
***
****
*****
Thank you very much.