var maxStar = 9
for (let i = 1; i < 10; i++) {
let half = maxStar-i
var totalSpaces = ' '.repeat(half)
process.stdout.write(totalSpaces)
for (let j = 0; j < i; j++) {
process.stdout.write('* ')
}
process.stdout.write('\n')
}
Output:
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
No comments:
Post a Comment