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

Inputcategory = "Adult"
Output25

02EXAMPLE 2

Inputcategory = "Alien"
Output0

Constraints

  • Return a number representing the price.
FundamentalsControl FlowSwitch
JavaScript
Loading...
3 Hidden

Input Arguments

category"Adult"

Expected Output

25

Click RUN to test your solution