The Forbidden Zone
MediumAcc. 89.1%
+30 XP 12
Avoiding the Diagonal
Sometimes you need to process an entire grid but skip specific patterns. The continue statement allows you to "jump over" an iteration and move straight to the next cycle of the loop.
The Assignment
Your function receives a parameter named max.
- Write an outer
forloop (i) from 1 tomax. - Write an inner
forloop (j) from 1 tomax. - Inside the inner loop, use an
ifstatement to check ifiis equal toj. - If they are equal, use
continueto skip printing. - If the loop continues (not equal), print the coordinate: (i, j).
01EXAMPLE 1
Input
max = 3Output
(1, 2)
(1, 3)
(2, 1)
(2, 3)
(3, 1)
(3, 2)Explanation: Skips (1,1), (2,2), and (3,3).
Constraints
- Use nested for loops.
- Use the continue statement.
- Log messages must match exactly.
LoopsControl FlowFundamentals
JavaScriptSystem handles I/O — write your function only
Loading...
2 Hidden
Input Arguments
max3
Expected Output
(1, 2) (1, 3) (2, 1) (2, 3) (3, 1) (3, 2)
Click RUN to test your solution