The X-Factor Grid
MediumAcc. 85.2%
+30 XP 12
Crossing Paths
An X-pattern occurs when symbols are placed on the two main diagonals of a square. Diagonal 1: $i = j$ Diagonal 2: $i + j = size - 1$
The Assignment
Your function receives a parameter size.
- Use nested loops to iterate through a
size x sizegrid. - If the cell is on either diagonal, print
*. - Otherwise, print a space.
- Ensure each row is printed on a new line.
01EXAMPLE 1
Input
size = 3Output
* *
*
* *Explanation: The 3x3 diagonal cross.
Constraints
- Ensure the formula i+j === size-1 is used.
- Handle even and odd sizes.
MathLoopsPatterns
JavaScriptSystem handles I/O — write your function only
Loading...
2 Hidden
Input Arguments
size3
Expected Output
* * * * *
Click RUN to test your solution