http://javascript.html.it/guide/lezione/895/lo-switch/

nel tuo caso però manterrei l'if.