JSworkingevergreen

Switch vs Lookup

Pick the right shape.

Long if/else if chains comparing one value against a fixed set of cases are a smell. switch is one fix — but a plain object lookup is often even better.

The classic switch

JSintro
Press Run to execute

'February' hits its case and returns Second; 'July' matches no case so the default arm returns Other — the baseline shape every later example replaces with a lookup.