This is how simple it could be: https://gist.github.com/tjwebb/11293598

`switch/case` statements should basically never be used in Javascript.