Instead of writing repetitive `else if` statements, use an array to look up the wanted value based on the key you have

Instead of writing repetitive `else if` statements, use an array to look up the wanted value based on the key you have

The code will be cleaner & more readable and you will see understandable exceptions if something goes wrong. No half-passing edge cases.

We're writing a book, you can get it for free here.