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.
- Write a
switchstatement onday:- 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
Input
day = "Monday"Output
Logs: "Start of the week."
Logs: "Mid-week pressure."Explanation: Execution falls into Tuesday.
02EXAMPLE 2
Input
day = "Friday"Output
Logs: "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
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
day"Monday"
Expected Output
Start of the week. Mid-week pressure.
Click RUN to test your solution