Skip to content

Commit 541a010

Browse files
authored
Create 08_Hollow_Square.js
1 parent e136b65 commit 541a010

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

22-Star-Pattern/08_Hollow_Square.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Q23: Print hollow square 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 === 1 || i === n || j === 1 || j === n) {
14+
line += "*";
15+
} else {
16+
line += " ";
17+
}
18+
}
19+
console.log(line);
20+
}

0 commit comments

Comments
 (0)