Skip to content

Commit 541cd5f

Browse files
authored
Create 09_X_Pattern.js
1 parent 541a010 commit 541cd5f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

22-Star-Pattern/09_X_Pattern.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Q24: Print X pattern
2+
// * *
3+
// * *
4+
// *
5+
// * *
6+
// * *
7+
8+
let n = 5;
9+
10+
for (let i = 1; i <= n; i++) {
11+
let line = "";
12+
for (let j = 1; j <= n; j++) {
13+
if (i === j || i + j === n + 1) {
14+
line += "*";
15+
} else {
16+
line += " ";
17+
}
18+
}
19+
console.log(line);
20+
}

0 commit comments

Comments
 (0)