The Domino Effect

MediumAcc. 89.7%
+15 XP 5

Gravity in Code

Normally, we use break to jump out of a switch block. But if you omit the break, JavaScript will "fall through" and execute the next case immediately, regardless of whether it matches or not! Like a chain of falling dominoes.

The Assignment

Your function receives a parameter named day.

  1. Write a switch statement on day:
    • Case "Monday": Print "Start of the week." (Caution: Do NOT use a break here!)
    • Case "Tuesday": Print "Mid-week pressure."
    • Default: Print "Relaxing day."

01EXAMPLE 1

Inputday = "Monday"
OutputLogs: "Start of the week." Logs: "Mid-week pressure."

Explanation: Execution falls into Tuesday.

02EXAMPLE 2

Inputday = "Friday"
OutputLogs: "Relaxing day."

Explanation: Hits the default case.

Constraints

  • Intentionally omit the break for the Monday case.
  • Log messages must match exactly including punctuation.
Control FlowConditionalsFundamentals
JavaScript
Loading...
3 Hidden

Input Arguments

day"Monday"

Expected Output

Start of the week.
Mid-week pressure.

Click RUN to test your solution