Thanks for your comment, I agree with you, the object literals looks better on js code, but my intention with this tutorial is to guide developers that have less experience in javascript, so a switch case sentence might looks more natural for them, I think that I can do a second part of this tutorial and do some code refactoring in some places, and also apply redux and other technologies, thanks for the feedbak :)
Use object literals instead of switch case and you have sort code.
This is example in my pokedex app.
Thanks for your comment, I agree with you, the object literals looks better on js code, but my intention with this tutorial is to guide developers that have less experience in javascript, so a switch case sentence might looks more natural for them, I think that I can do a second part of this tutorial and do some code refactoring in some places, and also apply redux and other technologies, thanks for the feedbak :)
No problem pro. Pokedex is my favorite app when I start begin new frontend Framework. Thanks for your post :) .
Btw, you can easily make it more type-safe:
You can do even better, just use enums:
Then, just access it: