We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0622591 commit baf77abCopy full SHA for baf77ab
reversedPyramid.js
@@ -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