We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 541cd5f commit 56010d0Copy full SHA for 56010d0
22-Star-Pattern/10_Diamond.js
@@ -0,0 +1,26 @@
1
+// Q25: Print diamond pattern
2
+// *
3
+// ***
4
+// *****
5
+// *******
6
+// *********
7
8
9
10
11
+
12
+let n = 5;
13
14
+// upper half
15
+for (let i = 1; i <= n; i++) {
16
+ let spaces = " ".repeat(n - i);
17
+ let stars = "*".repeat(2 * i - 1);
18
+ console.log(spaces + stars);
19
+}
20
21
+// lower half
22
+for (let i = n - 1; i >= 1; i--) {
23
24
25
26
0 commit comments