const getCommand = commands => word => key => key in commands ? commands[key](word) : null;
Wow! What is that? It sure looks cool but what is actually going on there?
That is a curried function and I hope to explain to you over the next page or two what that is and why you might prefer to write this function in that way rather than this:
function getCommand(commands, word, key) {