Skip to content

Commit e27a02d

Browse files
authored
Create 02_Pyramid.js
1 parent 68128fd commit e27a02d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

22-Star-Pattern/02_Pyramid.js

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

0 commit comments

Comments
 (0)