Skip to content

Commit baf77ab

Browse files
authored
Create reversedPyramid.js
1 parent 0622591 commit baf77ab

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

reversedPyramid.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Pseudocode:
2+
// FUNCTION printReversedPyramid(rows):
3+
// FOR i FROM 0 TO rows - 1 DO:
4+
// SET spaces TO ' ' REPEATED i TIMES
5+
// SET stars TO '*' REPEATED ((rows - i) * 2 - 1) TIMES
6+
// PRINT spaces + stars
7+
// END FUNCTION
8+
9+
function printReversedPyramid(rows) {
10+
for (let i = 0; i < rows; i++) {
11+
let spaces = ' '.repeat(i);
12+
let stars = '*'.repeat((rows - i) * 2 - 1);
13+
console.log(spaces + stars);
14+
}
15+
}
16+
17+
// Example usage
18+
printReversedPyramid(5);

0 commit comments

Comments
 (0)