Skip to content

Commit a4da66b

Browse files
authored
Create 03_Inverted_Triangle.js
1 parent e27a02d commit a4da66b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Q18: Print inverted triangle of stars
2+
// *****
3+
// ****
4+
// ***
5+
// **
6+
// *
7+
8+
let n = 5;
9+
10+
for (let i = n; i >= 1; i--) {
11+
let spaces = " ".repeat(n - i);
12+
let stars = "*".repeat(i);
13+
console.log(spaces + stars);
14+
}

0 commit comments

Comments
 (0)