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.

  1. Write an outer for loop (i) from 1 to max.
  2. Write an inner for loop (j) from 1 to max.
  3. Inside the inner loop, use an if statement to check if i is equal to j.
  4. If they are equal, use continue to skip printing.
  5. If the loop continues (not equal), print the coordinate: (i, j).

01EXAMPLE 1

Inputmax = 3
Output(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
JavaScript
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