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.
- Use a
switchstatement 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
Input
month = 2Output
Logs: "Q1 (Jan-Mar)"Explanation: Case 2 is grouped with 1 and 3.
02EXAMPLE 2
Input
month = 5Output
Logs: "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
JavaScriptSystem handles I/O — write your function only
Loading...
5 Hidden
Input Arguments
month2
Expected Output
Q1 (Jan-Mar)
Click RUN to test your solution