JS Built-ins
ControlFlowbeginner

Control Flow β€” switch statement

switch matches exact values

Use switch when you have many exact-value comparisons. Don't forget break between cases, or use return inside each case.

Challenge: Write dayName(n) that returns the day of the week for n=0..6 (0=Sunday) or 'Invalid' for other values.

πŸ’‘ Hints (1)
  • β€’ Use return inside each case to avoid needing break