The Quarter Master

EasyAcc. 95.9%
+15 XP 5

Case Grouping

Sometimes, different values should lead to the exact same outcome. Instead of repeating your code, you can "stack" multiple cases on top of each other. JavaScript will fall through them until it hits the first break.

The Assignment

Your function receives a number named month.

  1. Use a switch statement with grouping:
    • For cases 1, 2, and 3, print: "Q1 (Jan-Mar)"
    • For case 4, print: "Q2 starts"
    • For any other value (default), print: "After Q2"

01EXAMPLE 1

Inputmonth = 2
OutputLogs: "Q1 (Jan-Mar)"

Explanation: Case 2 is grouped with 1 and 3.

02EXAMPLE 2

Inputmonth = 5
OutputLogs: "After Q2"

Explanation: No case matches, hits default.

Constraints

  • Use a switch statement with at least one grouped case block.
  • Messages must match exactly including spaces and parentheses.
Control FlowConditionalsFundamentals
JavaScript
Loading...
5 Hidden

Input Arguments

month2

Expected Output

Q1 (Jan-Mar)

Click RUN to test your solution