Hollow Square Architect

MediumAcc. 88.4%
+30 XP 12

Structural Integrity

A hollow square is a grid where only the boundary cells contain a character (*), and the inner cells are empty.

The Assignment

Your function receives a parameter size.

  1. Use nested loops (i for rows, j for columns) from 0 to size - 1.
  2. If the current position is on the boundary (first row, last row, first column, or last column), print *.
  3. Otherwise, print a space.
  4. Correct spacing is essential: print a newline after each row.

01EXAMPLE 1

Inputsize = 3
Output*** * * ***

Explanation: A 3x3 hollow square.

Constraints

  • Use nested loops.
  • Only print symbols on the edges.
MathLoopsMastery
JavaScript
Loading...
2 Hidden

Input Arguments

size3

Expected Output

***
* *
***

Click RUN to test your solution