The Ticket Master
Easy+20 XP
Mission Briefing
The Grand Arena handles thousands of tickets daily, and the clerks are slowing down trying to remember all the pricing rules. They need an automated Ticket Master.
The Concept: The Switch Statement
When you have many specific values to check, a long chain of if/else if can get messy and hard to read. The switch statement is a much cleaner way to handle "branching" logic when checking a single variable against multiple exact matches.
The Objective
Your function receives a category string. Use a switch statement to return the ticket price based on these exact rules:
- "Child": return 10
- "Adult": return 25
- "Senior": return 15
- Default (Anything else): return 0
01EXAMPLE 1
Input
category = "Adult"Output
2502EXAMPLE 2
Input
category = "Alien"Output
0Constraints
- Return a number representing the price.
FundamentalsControl FlowSwitch
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
category"Adult"
Expected Output
25
Click RUN to test your solution